Twitter allows developers to create applications that integrate with the Twitter platform and use its services. It provides an API that has 3 parts:
- REST API
- Search API
- Streaming API, which is the latest one and allows long connections
Twitter REST API
The REST API is used by Twitter to expose their data as services. Developers can perform HTTP GET requests to obtain data like statuses and user information and HTTP POST requests to add data to Twitter, in case that they develop third-party clients.
Twitter Search API
The Twitter Search API is sued by develop to connect with the Twitter Search facility  and query the system for recent Tweets.
The Streaming API allows developers to perform real-time searches for Tweets. They construct queries and filters to make the search more specific.
Twitter into our System
In the scope of the Real-Time Aggregator system, Twitter REST API is more than enough. REST Architecture allows client to perform HTTP requests (POST, PUT, and GET). According to the REST Architecture , HTTP GET requests can retrieve resources from the Twitter system. Every strong-typed object oriented language, including Java, provides HTTP libraries that can be used to make such calls. The table below describes some of the most important GET requests that the Real-Time Aggregator will perform.
|Request (GET URL)||Resource Team|
Description: Returns the 10 hottest topics on Twitter in json format. By filtering them we will be able to identify any information specific to our searches.
Description: Returns the 30 hottest topics on Twitter for each day in the week in json format. By filtering them we will be able to identify any information specific to our searches.
Description: Returns the subscribers of a list in json or xml format.
Description: Returns the 20 latest favourite statuses for a user, whose id is given, in xml, json, atom or rss format.
Description: Returns the member of a list in xml or json format.
More information about resources and calls, together with information on how to consume the services can be found on the official Twitter API documentation .
Issues to bear in mind
Twitter Rest API has a usage limit and it sometimes constrains users to perform a temperate number of service requests. The limit for not authenticated users is 150 HTTP GET requests per hour, while the calls of authenticated users can be up to 350 HTTP GET requests per hour. The scope of our system contains only unauthenticated HTTP GET requests, performed to retrieve Twitter content. Although 150 requests per hour seem many, the limit constraints our real-time aggregator. In order to avoid any problems, there should be an inactivity period between the asynchronous requests made by our system. In cases that users reach the usage limit, the requests return an HTTP 400 error code (Bad request). The system shall be able to “catch” the error code and inform users.
Twitter Search API has some further limitations, which are mainly due to the date of the tweets that they return and to the complexity of the searching queries. The search queries return tweets, which are not older than a week. It also important that searching calls are not limited to a number of allowed requests. However, if a query is too complex, then an HTTP 420 error is returned informing the programmers about the wrong execution of the query. The system shall be able to “catch” the error code and inform users.