Stack Exchange API

Get Stack Exchange data as clean JSON with one key: 43 endpoints, 1 to 5 credits per call, the same response shape as every other platform.

What you get#

Onekey exposes Stack Exchange as 43 endpoints behind one API key: 6 endpoints return one record (data is an object) and 37 endpoints return a list (data is an array). Every answer uses the same envelope (success, data, metadata, error), the cost is reported in metadata.credits_charged, and fields are mapped onto the unified schema so the code you write for Stack Exchange also works for the rest of the messaging & communities category.

Endpoints#

EndpointWhat it doesParametersCreditsStatus
answerAn answer by id (with body).id*, site1stable
answersAnswers to a question (with body).id*, site5stable
badge_recipientsRecent recipients of a badge.id*, site5stable
badgesBadges of a site ranked by award rarity.site5stable
badges_tagTag-based badges of a site.site5stable
commentsLatest comments on a site.site5stable
infoSite statistics.site1stable
linkedQuestions that link to a question.id*, site5stable
moderatorsModerators of a site.site5stable
post_commentsComments on a post (question or answer).id*, site5stable
questionA question by id (with body).id*, site1stable
question_commentsComments on a question.id*, site5stable
questionsRecent active questions on a Stack Exchange site.site5stable
questions_by_tagNewest questions for a tag.tag*, site5stable
questions_featuredFeatured (bountied) questions on a Stack Exchange site.site5stable
questions_hotHot questions on a Stack Exchange site.site5stable
questions_unansweredUnanswered questions on a Stack Exchange site.site5stable
questions_votesMost-voted questions on a Stack Exchange site.site5stable
relatedQuestions related to a question.id*, site5stable
revisionsEdit revisions of a post.id*, site5stable
searchSearch Stack Exchange questions.q*, site5stable
search_excerptsSearch questions and answers with excerpts.q*, site5stable
similarQuestions similar to a title.q*, site5stable
sitesAll Stack Exchange network sites.-5stable
tag_infoTag statistics.tag*, site1stable
tag_relatedTags related to a tag.tag*, site5stable
tag_synonymsSynonyms of a tag.tag*, site5stable
tag_top_answerersTop answerers for a tag (all time).tag*, site5stable
tag_top_askersTop askers for a tag (all time).tag*, site5stable
tag_wikiWiki excerpt of a tag.tag*, site1stable
tagsPopular tags on a site.site5stable
tags_searchSearch tags by name.q*, site5stable
top_by_tagTop-voted questions for a tag.tag*, site5stable
userFetch a Stack Exchange user by numeric id.id*, site1stable
user_answersAnswers written by a user.id*, site5stable
user_badgesBadges earned by a user.id*, site5stable
user_commentsComments written by a user.id*, site5stable
user_questionsQuestions asked by a user.id*, site5stable
user_reputationRecent reputation changes of a user.id*, site5stable
user_tagsTags a user is active in.id*, site5stable
user_top_tagsA user's top tags by score.id*, site5stable
usersTop users by reputation on a site.site5stable
users_searchSearch users by name on a site.q*, site5stable

A * marks a required parameter. Each endpoint name links to its reference page with the full parameter table, caching window and a recorded response.

Make a request#

This calls stackexchange.answer (1 credit, stable). Replace YOUR_API_KEY with your key; sign up, no card. 1,000 free credits cover the open-platform endpoints. Hard-to-reach platforms (X, TikTok, Instagram, Reddit, and others marked on their page) need a verified email and a purchased pack.

curl "https://api.onekey.dev/v1/stackexchange/answer?id=11227902" \
  -H "x-api-key: YOUR_API_KEY"

Fields you get back#

These unified fields come back from Stack Exchange, with the same names as on every other platform. The count is how many of its 43 mapped endpoints return the field; a field the source lacks is null, never missing. 16 platform-specific fields (ext.<name>) come on top, documented on each endpoint page.

FieldTypeEndpoints
author.idstring29
author.usernamestring28
content.createdAtISO 8601 date28
author.avatarUrlURL27
author.urlURL27
author.reputationnumber26
engagement.likesinteger25
entity.namestring25
content.textstring23
content.idstring22
engagement.commentsinteger21
content.titlestring16
content.urlURL13
engagement.viewsinteger13
entity.idstring4
entity.urlURL4
author.locationstring3
content.typestring3
entity.descriptionstring3
entity.stats.rankinteger3
author.displayNamestring1
entity.typestring1
media.thumbnailUrlURL1
package.versionstring1

The full schema is in Unified schema.

Pricing#

Stack Exchange calls cost 1 to 5 credits, flat per endpoint. Free when served from cache (0.2 credit for a cached response over 100 KB). Invalid, failed or not-found calls are not charged. See pricing for credit packs.