Skip to main content
Stack Overflow for Teams API v2.3

How to access and update your data with API v2.3.

Loren Alldrin avatar
Written by Loren Alldrin
Updated this week

Tags | Integrations | API |

Applies to: Basic, Business

Enterprise users can access their documentation here. Find your plan.


Overview

Though Stack Overflow still supports API v2.3, we encourage all users to migrate to the improved API v3. Learn more about API v3.

The Stack Overflow for Teams API enables you to interact with your Stack Overflow site programmatically with external scripts, reporting tools and automated workflows. Business Teams can use the API to read and write data, while Basic Teams have read-only API access. Free Teams do not have API access.

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 v2.3

The base URL for API v2.3 access is https://api.stackoverflowteams.com/v2.3/teams/[your_team]/. API v2.3 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 v2.3 call requires both of these components:

  1. Teams API base URL plus endpoint
    Use the base API v2.3 URL plus the specific endpoint. To retrieve a list of questions, for example, the API URL would be https://api.stackoverflowteams.com/v2.3/teams/[your_team]/questions.

  2. PAT (as a bearer token)
    Pass the PAT in the API call header as the Authorization: Bearer value, like this: Authorization: Bearer abcdefgh12345678.

API documentation sandbox

The best way to learn how to use a PAT with the Stack Overflow API is through the API documentation sandbox. Start by accessing the Stack Overflow API v2.3 documentation at https://api.stackoverflowteams.com/docs. The top of the page has general information about the API; further down the page you'll find the specific API endpoints (queries) you can access.

Click one of the endpoint links (for example: questions) to see more information about that API query. You can also access the documentation for a specific endpoint directly like this: https://api.stackoverflowteams.com/docs/questions.

Scroll to the bottom of the page to the "Try it" area. You can use this tool to test out Teams API v2.3 calls with your PAT.

Enter your team slug into the Team slug field, and your PAT into the Access token field. Click Run. The API query should return question data, displayed beneath the API URL.

Use the additional "Try it" fields and pull-down menus to control the API query and the data it returns. You can also add other fields to the return data by clicking [edit] in the upper-right filter area. When you're done testing, use the generated URL as a starting point for creating your own automated API calls.

Here are two examples that show the API URL in use.

CURL
​curl --header "X-API-Access-Token: [PAT]" 'https://api.stackoverflowteams.com/2.3/questions?order=desc&sort=activity&team=[team_slug]' | gunzip

PowerShell
​ powershell (Invoke-WebRequest 'https://api.stackoverflowteams.com/2.3/questions?order=desc&sort=activity&team=[team_slug]' -Headers @{"X-API-Access-Token"="[PAT]"}).Content | ConvertFrom-Json | ConvertTo-Json

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 v2.3 uses request throttling to prevent abuse and maintain site performance and stability. These throttles include an overall request limit per day per user, dynamic throttles (which generate the backoff parameter), and burst throttles to limit the number of write actions completed in quick succession.

API v2.3 throttling thresholds are generous. If your site begins throttling API calls, consider whether you're using the API as efficiently as possible. For example: no application should make semantically identical requests more than once a minute. This can be a waste of bandwidth as it usually returns the same data.

Troubleshooting

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.

Did this answer your question?