Tags | API |
Enterprise users can access their documentation here. Find your plan.
Overview
The Stack Overflow for Teams API enables you to interact with your Stack Overflow Enterprise (SOE) site programmatically with external scripts, reporting tools and automated workflows. You can read about general API v3 features in the API v3 Overview article.
NOTE: Stack Overflow for Teams Basic offers read-only API v3 access. Stack Overflow for Teams Business offers both read-only and read/write access.
THIS ARTICLE APPLIES TO STACK OVERFLOW FOR TEAMS BASIC AND BUSINESS ONLY.
Stack Overflow for Teams Enterprise users should read this article instead. Find your plan.
Access API v3
The base URL for API v3 access is https://api.stackoverflowteams.com/v3/teams/[your_team]/. API v3 requires a personal access token (PAT) to authorize each API request. Learn more about PAT authorization in the PAT API Authorization article.
A successful API v3 call requires both of these components:
Teams API base URL plus endpoint
Use the base API v3 URL plus the specific endpoint. To retrieve a list of questions, for example, the API URL would be https://api.stackoverflowteams.com/v3/teams/[your_team]/questions.PAT (as a bearer token)
Pass the PAT in the API call header as theAuthorization: Bearer
value, like this:Authorization: Bearer
abcdefgh12345678
.
Interactive API documentation
In addition to this document, your site has interactive documentation with definitions for all API v3 methods and data models. This interactive documentation system (Swagger UI) allows you to test API calls and view returned data in a convenient web interface with no API implementation required. You can access the interactive API documentation at https://api.stackoverflowteams.com/v3.
Swagger UI functions as an API application with full access to API v3 as the authenticated user. When authorized, Swagger UI uses its access key to create its own PAT code. PATs created through Swagger UI expire after 24 hours.
NOTE: You don't have to wait for the 24-hour period to end to create a new Swagger UI access token. To delete the existing token and create a new one, click Authorize, then Logout, then Authorize again.
To authorize Swagger UI:
Click Authorize. An "Available authorizations" box will appear.
Leave client_id unchanged.
Check write_access if the token should have write permissions (Business only).
Make sure access_team is checked.
Click Authorize.
You can view your PAT list by clicking your avatar (profile picture), then Account settings, then Personal access tokens under the "API" heading. Your PAT list will show a "Created by Swagger UI" PAT for each team you authorize Swagger UI to access.
You can also use the PAT code for API calls outside of Swagger UI, which may be useful for temporary API application development or testing. When you use Swagger UI to access API v3, Swagger UI reveals its PAT code as part of the underlying API call. You can find the code in the "Curl" section of the Swagger UI execution output. Look for the following line:
-H 'Authorization: Bearer [PAT code]))'
API write operations
Using the Stack Overflow API to add or edit content involves additional considerations and concerns. If not done with care, automating the addition of new content can actually decrease user engagement. Learn more about using the API to write data in the Use the Write API article.
Throttling
API v3 uses throttling to maintain site performance and stability. Learn more about throttling and rate-limiting information in the API v3 Overview article.
Troubleshooting
Stack Overflow API v3 follows the OpenAPI Specification (OAS), and will return standardized status codes for all errors to aid in troubleshooting. If you experience errors, Swagger UI can be helpful in exploring the structure of API requests and their returned data. You’ll also find schemas for all API endpoints at the bottom of the Swagger UI page.
To maintain security of data and stability of the site, Stack Overflow will reject certain API requests. Here are some of the most common reasons:
Invalid/missing PAT
Invalid/missing Team slug
Expired PAT
PAT not associated with specified team
Write operation specified for read-only PAT
Inadequate user permissions
Too many API calls in a given time period (throttling)
Need help? Submit an issue or question through our support portal.