Twitter REST API Method: friends ids

Page history last edited by Alex Payne 1 mo ago

<< Back to Twitter API Documentation

 

friends/ids

Returns an array of numeric IDs for every user the specified user is following.

method status | report a bug

 

URL:

http://twitter.com/friends/ids.format

 

Formats: 

xml, json

 

HTTP Method(s):

GET

 

Requires Authentication (about authentication):

false unless requesting it from a protected user; if getting this data of a protected user, you must auth (and be allowed to see that user).

 

API rate limited (about rate limiting):

1 call per request

 

Parameters:

  • One of the following:
    • id.  Optional.  The ID or screen_name of the user to retrieve the friends ID list for.
      • Example: http://twitter.com/friends/ids/bob.xml
    • user_id.  Optional.  Specfies the ID of the user for whom to return the friends list. Helpful for disambiguating when a valid user ID is also a valid screen name.
      • Example: http://twitter.com/friends/ids.xml?user_id=1401881
    • screen_name.  Optional.  Specfies the screen name of the user for whom to return the friends list. Helpful for disambiguating when a valid screen name is also a user ID.
      • Example: http://twitter.com/friends/ids.xml?screen_name=101010
  • cursor. Optional. Breaks the results into pages. A single page contains 5000 ids. This is recommended for users with large ID lists. Provide a value of -1 to begin paging. Provide values as returned to in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
    • Example: http://twitter.com/friends/ids/barackobama.xml?cursor=-1
    • Example: http://twitter.com/friends/ids/barackobama.xml?cursor=-1300794057949944903

 

Notes:

  • If the cursor parameter is not provided, all IDs are attempted to be returned, but large sets of IDs will likely fail with timeout errors.
  • Paged result sets aren't guaranteed to contain 5000 IDs, as suspended users will be filtered out.
  • The previously documented page-based pagination mechanism is still in production, but please migrate to cursor-based pagination for increase reliability and performance.

 

Response (about return values): 

          XML example (truncated):

<?xml version="1.0" encoding="UTF-8"?> 

<id_list>

     <ids>

          <id>30592818</id>

          <id>21249843</id>

          ... truncated ...

     </ids>

     <next_cursor>1288724293877798413</next_cursor>

     <previous_cursor>-1300794057949944903</previous_cursor>

</id_list>

 

Usage examples: 

cURL (about cURL):

curl http://twitter.com/friends/ids/dougw.xml

curl http://twitter.com/friends/ids.xml?screen_name=dougw

 

          Do you have an example to share in the language of your choice? Please share!

 

<< Back to Twitter API Documentation

Comments (0)

You don't have permission to comment on this page.