Things Every Developer Should Know

Tweet IDs are enormous and break Javascript

Use the id_str field instead of id whenever present to stay safe. Your web browser/Javascript interpreter/JSON consumer may munge our large integer-based ids which is why it’s recommended to use the string representation. See Twitter IDs, JSON and Snowflake.

The contents of the FAQ

If you are starting with the API, please familiarize yourself with the API FAQ and know that it exists.

There are many APIs

The public Twitter API currently consists of two discrete REST APIs and a Streaming API. Most application developers mix and match the APIs to produce their application. The API Overview portion of the Getting Started series explains the history. The Streaming API provides low-latency high-volume access to Tweets.

There are limits to how many calls and changes you can make in a day

API usage is rate limited with additional fair use limits to protect Twitter from abuse.

The API is entirely HTTP-based (over SSL)

Methods to retrieve data from the Twitter API require a GET request. Methods that submit, change, or destroy data require a POST. A DELETE request is also accepted for methods that destroy data. API Methods that require a particular HTTP method will return an error if you do not make your request with the correct one. HTTP Response Codes are meaningful.

The API is a RESTful resource

With the exception of the Streaming API, the Twitter API attempts to conform to the design principles of Representational State Transfer (REST). Twitter APIs use the JSON data format.

Parameters have certain expectations

Some API methods take optional or requisite parameters. Keep in mind when making requests with parameters:

  • Parameter values should be converted to UTF-8 and URL encoded.
  • The page parameter begins at 1, not 0.

Where noted, some API methods will return different results based on HTTP headers sent by the client. Where the same behavior can be controlled by both a parameter and an HTTP header, the parameter will take precedence.

There are pagination limits

Rest API Limit

Clients may access a theoretical maximum of 3,200 statuses via the page and count parameters for the user_timeline REST API methods. Other timeline methods have a theoretical maximum of 800 statuses. Requests for more than the limit will result in a reply with a status code of 200 and an empty result in the format requested. Twitter still maintains a database of all the tweets sent by a user. However, to ensure performance of the site, this artificial limit is temporarily in place.

There are Twitter API libraries for almost any language

The community has created numerous Twitter API libraries. If you know of others we haven’t got let us know.