Tags | API | Automation |
Overview
Stack Overflow for Teams API v3 enables you to interact with your Stack Overflow for Teams site programmatically with external scripts, reporting tools, and automated workflows.
How you authenticate into and access API v3 depends on your Stack Overflow for Teams version. Follow the appropriate link below to learn more.
Stack Overflow for Teams Free has no API access. Teams Basic offers read-only API v3 access, while Teams Business and Enterprise can use API v3 to read and write. Find your plan.
In addition to the general API support documentation, 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. For more information, see the "Interactive API v3 documentation" section of the relevant document linked above.
Throttling
Stack Overflow for Teams API v3 uses request throttling to prevent abuse and ensure optimum performance for all users. We currently implement two different types of throttling to alleviate excessive API calls: burst throttle rate limiter (short-term ) and token bucket rate limiter (long-term). Both throttling methods monitor the number of requests coming from each access token.
Burst throttle rate limiter
The burst throttle rate limiter engages when an access token makes too many requests during a brief window of time. The default for this limiter is 50 requests in a two-second interval.
The burst throttle rate limiter returns two headers with information about throttling status:
x-burst-throttle-calls-left The number of calls left in the time window before the throttle begins rejecting API calls.
x-burst-throttle-seconds-until-full The number of seconds left in the throttle time window.
Token bucket rate limiter
As its name implies, API v3's token bucket rate limiter manages a "bucket" of request tokens. Each API request consumes a token from the bucket. When API requests consume all the tokens in the bucket, API v3 will reject subsequent requests. API v3 refills the bucket with a set number of tokens each second. When the request token bucket is full, API v3 stops adding tokens. The default max tokens setting is 5000, with a refill rate of 100 tokens every 60 seconds.
API v3 responses include three headers with information about the token bucket rate limiter status:
TokenBucket_MaxTokens The maximum number of tokens the bucket will hold (when the API will stop adding tokens).
TokenBucket_RefillSeconds The interval of time between refills.
TokenBucket_RefillTokens The number of tokens the API adds at each refill.
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.
Need help? Submit an issue or question through our support portal.