Don’t have time to reread all the prior poetry about the Twitter API? Fine. Here’s a methods cheat sheet that gives you the basics you will need to program your Twitter application. The hierarchy listed here is based on the server paths used by Twitter—the technical order, based on path and method name—rather than the functional groups I used in Chapter 4, Meet the Twitter API of this book.
This excerpt is from Twitter API: Up and Running . This groundbreaking book provides you with the skills and resources you need to build web applications for Twitter. Perfect for new and casual programmers intrigued by the microblogging, Twitter API: Up and Running carefully explains how each part of Twitter's API works, with detailed examples that show you how to assemble those building blocks into practical and fun web applications.
Twitter tracks two kinds of rate limits: one for unauthenticated
requests (which is not possible for the methods that require
authentication), and the other for requests made per account when
authentication is used. POST method
requests, used whenever you need to make a change to the server, don’t cost
anything. There are also a few methods that are exempt from the rate
limit.
For more information on the current nuances of using the API, check out the Twitter API FAQ.
In this appendix, I use the .xml format to describe the methods. Remember, you can substitute .json for all of the Twitter API methods and .atom or .rss for some of them.
Removes a single status update from the Twitter timeline.
Returns a list of people who follow you.
Returns a list of people you follow.
Path |
| |
Requires authentication | Yes, if the account is private (authenticating user must be allowed by the author to view the list of friends). | |
Charged against rate limit | Yes. | |
HTTP method type | GET. | |
Optional parameters | ||
| Indicates the user ID or
username of the Twitter account whose following list you want to
view. The | |
| Indicates which page of 100 users to return. The default is 1 (users most recently followed). | |
Successful output | ||
There are newer methods that allow you to get the entire list of followers and friends as user IDs. No other information is included in the Twitter API response, but it does save on pagination. See the section called “Get All Followers” and the section called “Get All Friends”.
Returns the most recent status updates made by people you follow.
Returns the most recent status updates from public accounts with custom pictures.
Path |
| |
Requires authentication | No. | |
Charged against rate limit | No. | |
HTTP method type | GET. | |
Successful output | ||
Returns the most recent status updates from people who have replied to you.
Returns a single status update with the given ID.
Path |
| |
Requires authentication | Yes, if the status update is private (authenticating user must be allowed by the author to view the text). | |
Charged against rate limit | Yes. | |
HTTP method type | GET. | |
Required parameters | ||
| Provides the record ID
for an existing status update owned by the authenticating user.
The | |
Successful output | ||
Creates a new status update authored by you.
Returns the most recent status updates for a specific account.
Returns your profile and statistical details.
Returns the most recent direct messages you have received.
Deletes an existing direct message received by you.
Path |
| |
Requires authentication | Yes (authenticating user owns the message). | |
Charged against rate limit | No. | |
HTTP method type | POST or DELETE. | |
Required parameters | ||
| Provides the record ID
for an existing message owned by the authenticating user. The
| |
Successful output | ||
Creates a new direct message sent from you to another user.
Returns the most recent direct messages you have sent.
Creates a new follow relationship between you and another Twitter member.
Path |
| |
Requires authentication | Yes. | |
Charged against rate limit | No. | |
HTTP method type | POST. | |
Required parameters | ||
| Provides the user ID or
username of an existing Twitter member not already followed by
the authenticating user. The | |
| Adds device notifications for this friend, in addition to following that member. See the section called “Turn On Notification”. | |
Successful output | ||
Removes an existing follow relationship with another Twitter member.
Path |
| |
Requires authentication | Yes. | |
Charged against rate limit | No. | |
HTTP method type | POST. | |
Required parameters | ||
| Provides the user ID or
username of an existing Twitter member already being followed by
the authenticating user. The | |
Successful output | ||
Verifies whether one Twitter member is following another.
Returns the full list of people you follow.
Path |
| |
Requires authentication | Yes, if the account is private (authenticating user must be allowed by the author to view the list of friends). | |
Charged against rate limit | Yes. | |
HTTP method type | GET. | |
Optional parameters | ||
| Indicates the user ID or
username of the Twitter account whose following list you want to
view. The | |
Successful output | ||
Returns the full list of people who follow you.
Path |
| |
Requires authentication | Yes (authenticating user must be allowed by the author to view a private list of followers). | |
Charged against rate limit | Yes. | |
HTTP method type | GET. | |
Optional parameters | ||
| Indicates the user ID or
username of the Twitter account whose follower list you want to
view. The | |
Successful output |
||
Tells Twitter that your application is finished using your access credentials.
Path |
|
Requires authentication | Yes (affects authenticating user). |
Charged against rate limit | No. |
HTTP method type | POST. |
Successful output |
Checks to see how many hourly hits on the API are left for your account.
Path |
|
Requires authentication | No. If authenticated, returns the rate limit for that Twitter account. If unauthenticated, returns the rate limit for the IP address used to make the request. |
Charged against rate limit | No. |
HTTP method type | GET. |
Successful output |
Selects a device for you to use to receive updates.
There is currently no Twitter support for IM notifications.
Changes the location information stored in your profile.
The update_location method
has been deprecated in favor of the update_profile method, which contains an
optional parameter for location.
To keep your application from breaking in the future, avoid using
update_location.
Sets the values of selected fields found in the “Account” tab under the settings on the Twitter website.
Changes the background image on the authenticating user’s member profile web page.
Changes the color scheme applied to the authenticating member’s profile page.
Changes the picture associated with the authenticating member’s account and displayed with that user’s tweets.
Returns a list of all status updates you’ve flagged as favorites.
Flags a status update as a favorite.
Path |
| |
Requires authentication | Yes. | |
Charged against rate limit | No. | |
HTTP method type | POST. | |
Required parameters | ||
| References the ID of an
existing status update. The | |
Successful output | ||
Removes an existing flag on one of the authenticating member’s favorite status updates.
Path |
| |
Requires authentication | Yes. | |
Charged against rate limit | No. | |
HTTP method type | POST or DELETE. | |
Required parameters | ||
| References the ID of an
existing status update that the authenticating user has already
made a favorite. The | |
Successful output | ||
Tells Twitter to start sending an author’s updates to the preferred device.
Path |
| |
Requires authentication | Yes (affects authenticating user). | |
Charged against rate limit | No. | |
HTTP method type | POST. | |
Required parameters | ||
| Provides the user ID or
username of another member to be followed by the authenticating
user. The | |
Successful output | ||
Tells Twitter to stop sending an author’s updates to the specified device.
Path |
| |
Requires authentication | Yes (affects authenticating user). | |
Charged against rate limit | No. | |
HTTP method type | POST. | |
Required parameters | ||
| Provides the user ID or
username of another member followed by the authenticating user.
The | |
Successful output | ||
Keeps another member from following your updates.
Path |
| |
Requires authentication | Yes. | |
Charged against rate limit | No. | |
HTTP method type | POST. | |
Required parameters | ||
| Provides the user ID or
username of an existing Twitter member not already blocked by
the authenticating user. The | |
Successful output | ||
Allows another member to once again follow your updates.
Path |
| |
Requires authentication | Yes. | |
Charged against rate limit | No. | |
HTTP method type | POST or DELETE. | |
Required parameters | ||
| Supplies the user ID or
username of an existing Twitter member already blocked by the
authenticating user. The | |
Successful output | ||
Searches for keyword matches in tweet content.
If you enjoyed this excerpt, buy a copy of Twitter API: Up and Running.
Copyright © 2009 O'Reilly Media, Inc.