Updated on Mon, 2012-05-14 09:32
HTTP Status Codes
The Twitter API attempts to return appropriate HTTP status codes for every request. It is possible to suppress response codes for the REST API.
| Code | Text | Description |
|---|---|---|
| 200 | OK | Success! |
| 304 | Not Modified | There was no new data to return. |
| 400 | Bad Request | The request was invalid. An accompanying error message will explain why. This is the status code will be returned during rate limiting. |
| 401 | Unauthorized | Authentication credentials were missing or incorrect. |
| 403 | Forbidden | The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits. |
| 404 | Not Found | The URI requested is invalid or the resource requested, such as a user, does not exists. |
| 406 | Not Acceptable | Returned by the Search API when an invalid format is specified in the request. |
| 420 | Enhance Your Calm | Returned by the Search and Trends API when you are being rate limited. |
| 500 | Internal Server Error | Something is broken. Please post to the group so the Twitter team can investigate. |
| 502 | Bad Gateway | Twitter is down or being upgraded. |
| 503 | Service Unavailable | The Twitter servers are up, but overloaded with requests. Try again later. |
| 504 | Gateway timeout | The Twitter servers are up, but the request couldn't be serviced due to some failure within our stack. Try again later. |
Error Messages
When the Twitter API returns error messages, it does so in your requested format. For example, an error from a JSON method might look like this:
{"errors":[{"message":"Sorry, that page does not exist","code":34}]}
The corresponding XML response would be:
<?xml version="1.0" encoding="UTF-8"?><errors><error code="34">Sorry, that page does not exist</error>
</errors>
Error Codes
In addition to descriptive error text, error messages contain machine-parseable codes. While the text for an error message may change, the codes will stay the same. The following table describes the codes which may appear when working with the API:
| Code | Text | Description |
|---|---|---|
| 34 | Sorry, that page does not exist | Corresponds with an HTTP 404 - the specified resource was not found. |
| 130 | Over capacity | Corresponds with an HTTP 503 - Twitter is temporarily over capacity. |
| 131 | Internal error | Corresponds with an HTTP 500 - An unknown internal error occurred. |
If you see an error response which is not listed in the above table, then fall back to the HTTP status code in order to determine the best way to address the error.