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 today

Tags | Integrations | API |

Applies to: Basic, Business

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


Overview

NOTE: 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. For general information about API v2.3, including using the API to write data, throttling, and troubleshooting, read the API v2.3 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. Stack Overflow for Teams Free does not have API 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.

API v2.3 access and authentication

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

API call examples

Here are two examples of API v2.3 calls.

CURL API call

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

PowerShell API call

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


Need help? Submit an issue or question through our support portal.

Did this answer your question?