Skip to content

StackExchange API

by stackexchange.com

OAuthHTTPSDevelopment
Open documentation ↗

Overview

Q&A forum for developers

StackExchange is a development API from stackexchange.com. Requests are authenticated with OAuth. It is served over HTTPS. Its OpenAPI description documents 124 endpoints.

At a glance

Authentication
OAuth
HTTPS
Yes
CORS
Unknown
Category
Development
Base URL
https://api.stackexchange.com/2.0
Version
2.0
Endpoints
124
Spec updated
2021-06-21

Make a first request

Replace the placeholders; the documentation says exactly where credentials go.

cURL
curl -X GET "https://api.stackexchange.com/2.0/answers" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"
JavaScript
const response = await fetch("https://api.stackexchange.com/2.0/answers", {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
});
const data = await response.json();
console.log(data);
Python
import requests

response = requests.request(
    "GET",
    "https://api.stackexchange.com/2.0/answers",
    headers={
    "Accept": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
    },
    timeout=30,
)
print(response.json())

Endpoints

MethodPathWhat it does
GET/access-tokens/{accessTokens}Reads the properties for a set of access tokens.
GET/access-tokens/{accessTokens}/invalidateImmediately expires the access tokens passed. This method is meant to allow an application to discard any active access tokens it no longer needs.
GET/answersReturns all the undeleted answers in the system.
GET/answers/{ids}Gets the set of answers identified by ids.
GET/answers/{ids}/commentsGets the comments on a set of answers.
GET/apps/{accessTokens}/de-authenticatePassing valid access_tokens to this method causes the application that created them to be de-authorized by the user associated with each access_token. This will
GET/badgesReturns all the badges in the system.
GET/badges/nameGets all explicitly named badges in the system.
GET/badges/recipientsReturns recently awarded badges in the system.
GET/badges/tagsReturns the badges that are awarded for participation in specific tags.
GET/badges/{ids}Gets the badges identified in id.
GET/badges/{ids}/recipientsReturns recently awarded badges in the system, constrained to a certain set of badges.
GET/commentsGets all the comments on the site.
GET/comments/{ids}Gets the comments identified in id.
POST/comments/{id}/deleteDeletes a comment.
POST/comments/{id}/editEdit an existing comment.
GET/errorsReturns the various error codes that can be produced by the API.
GET/errors/{id}This method allows you to generate an error.
GET/eventsReturns a stream of events that have occurred on the site.
GET/filters/createCreates a new filter given a list of includes, excludes, a base filter, and whether or not this filter should be "unsafe".
GET/filters/{filters}Returns the fields included by the given filters, and the "safeness" of those filters.
GET/inboxReturns a user's inbox.
GET/inbox/unreadReturns the unread items in a user's inbox.
GET/infoReturns a collection of statistics about the site.
GET/meReturns the user associated with the passed access_token.
GET/me/answersReturns the answers owned by the user associated with the given access_token.
GET/me/associatedReturns all of a user's associated accounts, given an access_token for them.
GET/me/badgesReturns the badges earned by the user associated with the given access_token.
GET/me/commentsReturns the comments owned by the user associated with the given access_token.
GET/me/comments/{toId}Returns the comments owned by the user associated with the given access_token that are in reply to the user identified by {toId}.
GET/me/favoritesReturns the questions favorites by the user associated with the given access_token.
GET/me/inboxReturns the user identified by access_token's inbox.
GET/me/inbox/unreadReturns the unread items in the user identified by access_token's inbox.
GET/me/mentionedReturns the comments mentioning the user associated with the given access_token.
GET/me/mergesReturns a record of merges that have occurred involving a user identified by an access_token.
GET/me/notificationsReturns a user's notifications, given an access_token.
GET/me/notifications/unreadReturns a user's unread notifications, given an access_token.
GET/me/privilegesReturns the privileges the user identified by access_token has.
GET/me/questionsReturns the questions owned by the user associated with the given access_token.
GET/me/questions/featuredReturns the questions that have active bounties offered by the user associated with the given access_token.
GET/me/questions/no-answersReturns the questions owned by the user associated with the given access_token that have no answers.
GET/me/questions/unacceptedReturns the questions owned by the user associated with the given access_token that have no accepted answer.
GET/me/questions/unansweredReturns the questions owned by the user associated with the given access_token that are not considered answered.
GET/me/reputationReturns the reputation changed for the user associated with the given access_token.
GET/me/reputation-historyReturns user's public reputation history.
GET/me/reputation-history/fullReturns user's full reputation history, including private events.
GET/me/suggested-editsReturns the suggested edits the user identified by access_token has submitted.
GET/me/tagsReturns the tags the user identified by the access_token passed is active in.
GET/me/tags/{tags}/top-answersReturns the top 30 answers the user associated with the given access_token has posted in response to questions with the given tags.
GET/me/tags/{tags}/top-questionsReturns the top 30 questions the user associated with the given access_token has posted in response to questions with the given tags.
GET/me/timelineReturns a subset of the actions the user identified by the passed access_token has taken on the site.
GET/me/top-answer-tagsReturns the user identified by access_token's top 30 tags by answer score.
GET/me/top-question-tagsReturns the user identified by access_token's top 30 tags by question score.
GET/me/write-permissionsReturns the write permissions a user has via the api, given an access token.
GET/notificationsReturns a user's notifications.
GET/notifications/unreadReturns a user's unread notifications.
GET/postsFetches all posts (questions and answers) on the site.
GET/posts/{ids}Fetches a set of posts by ids.
GET/posts/{ids}/commentsGets the comments on the posts identified in ids, regardless of the type of the posts.
GET/posts/{ids}/revisionsReturns edit revisions for the posts identified in ids.
GET/posts/{ids}/suggested-editsReturns suggsted edits on the posts identified in ids.
POST/posts/{id}/comments/addCreate a new comment.
GET/privilegesReturns the earnable privileges on a site.
GET/questionsGets all the questions on the site.
GET/questions/featuredReturns all the questions with active bounties in the system.
GET/questions/no-answersReturns questions which have received no answers.
GET/questions/unansweredReturns questions the site considers to be unanswered.
GET/questions/{ids}Returns the questions identified in {ids}.
GET/questions/{ids}/answersGets the answers to a set of questions identified in id.
GET/questions/{ids}/commentsGets the comments on a question.
GET/questions/{ids}/linkedGets questions which link to those questions identified in {ids}.
GET/questions/{ids}/relatedReturns questions that the site considers related to those identified in {ids}.
GET/questions/{ids}/timelineReturns a subset of the events that have happened to the questions identified in id.
GET/revisions/{ids}Returns edit revisions identified by ids in {ids}.
GET/searchSearches a site for any questions which fit the given criteria.
GET/search/advancedSearches a site for any questions which fit the given criteria.
GET/similarReturns questions which are similar to a hypothetical one based on a title and tag combination.
GET/sitesReturns all sites in the network.
GET/suggested-editsReturns all the suggested edits in the systems.
GET/suggested-edits/{ids}Returns suggested edits identified in ids.
GET/tagsReturns the tags found on a site.
GET/tags/moderator-onlyReturns the tags found on a site that only moderators can use.
GET/tags/requiredReturns the tags found on a site that fulfill required tag constraints on questions.
GET/tags/synonymsReturns all tag synonyms found a site.
GET/tags/{tags}/faqReturns the frequently asked questions for the given set of tags in {tags}.
GET/tags/{tags}/infoReturns tag objects representing the tags in {tags} found on the site.
GET/tags/{tags}/relatedReturns the tags that are most related to those in {tags}.
GET/tags/{tags}/synonymsGets all the synonyms that point to the tags identified in {tags}. If you're looking to discover all the tag synonyms on a site, use the /tags/synonyms methods
GET/tags/{tags}/wikisReturns the wikis that go with the given set of tags in {tags}.
GET/tags/{tag}/top-answerers/{period}Returns the top 30 answerers active in a single tag, of either all-time or the last 30 days.
GET/tags/{tag}/top-askers/{period}Returns the top 30 askers active in a single tag, of either all-time or the last 30 days.
GET/usersReturns all users on a site.
GET/users/moderatorsGets those users on a site who can exercise moderation powers.
GET/users/moderators/electedReturns those users on a site who both have moderator powers, and were actually elected.
GET/users/{ids}Gets the users identified in ids in {ids}.
GET/users/{ids}/answersReturns the answers the users in {ids} have posted.
GET/users/{ids}/associatedReturns all of a user's associated accounts, given their account_ids in {ids}.
GET/users/{ids}/badgesGet the badges the users in {ids} have earned.
GET/users/{ids}/commentsGet the comments posted by users in {ids}.
GET/users/{ids}/comments/{toid}Get the comments that the users in {ids} have posted in reply to the single user identified in {toid}.

Showing the first 100 of 124 endpoints; the full list is in the documentation.

Questions

Does the StackExchange API need an API key?

Yes. The StackExchange API uses OAuth authentication; the documentation explains how to get credentials.

Does the StackExchange API support HTTPS?

Yes, the StackExchange API is served over HTTPS.

How many endpoints does the StackExchange API have?

Its OpenAPI description lists 124 endpoints in version 2.0. The first 100 are shown on this page.

What are alternatives to the StackExchange API?

Other Development APIs include Cloudflare, Azure DevOps, IPify, App Store Connect API, IPinfo.

Compare alternatives →

Listed from public-apis (MIT), public-apis database (MIT), APIs.guru (CC0).