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.
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. API v3 uses modern API design patterns, making it easy and familiar for both developers and end users. Learn more about Swagger UI.
How you will 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 Basic offers read-only API v3 access. Team Business and Enterprise plans can use API v3 to read and write. Find your plan.
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 over both short and long time intervals. Both 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.
Adding content by API
Stack Overflow for Teams Business and Enterprise users can use the write-enabled API v3 to add content to their site, but should do so with caution. Adding content with API automation requires extra care because the results can feel machine-generated or otherwise out of place. This may cause users to ignore new API-generated content, lose engagement, and stop contributing.
Examples of API integrations that may have detrimental effects on engagement include:
Adding all entries from some other system (like an error logger or chat system) as new questions on your Stack Overflow for Teams site.
Allowing users to add new questions through a different interface or site, without an understanding of the Stack Overflow for Teams site itself or how the content will appear.
Automatically posting the same boilerplate text as an answer to all questions.
All content on your site should feel appropriate and relevant, including content added by API. We recommend that all write-enabled API integrations ensure users understand where their content/contributions will appear on the Stack Overflow for Teams site. They should also require an explicit user action before posting.
Be sure to contact your site administrator to discuss your objectives and planned implementation before using the API's write capabilities.
Need help? Submit an issue or question through our support portal.