Getting all friend list by friends/list REST API request (15 requests in 15 minutes problem)


#1

Hi! I’m making “friends/list” request, that returns me up to 20 users. And the limit of the request is 15 requests per 15 minutes. How can I get all friends if the user follows more then 300 (15x20) users. Or user makes 2 requests in 15 min. with 150+ friends e.t.c ?

Obj-c code sample:

NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/friends/list.json"];
NSDictionary *params = @{@"user_id"               : _twitterUserAccount.identifier,
                                          @"skip_status"           : @"true",
                                          @"cursor"                : _cursor ? _cursor: @"-1",
                                          @"include_user_entities" :@"true"};
 SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
                                    requestMethod:SLRequestMethodGET
                                              URL:url
                                       parameters:params];

[request performRequestWithHandler:^(NSData *responseData,
                                                      NSHTTPURLResponse *urlResponse,
                                                      NSError *error) {
...
}];

#2

The use case for friends/list is pretty limited. Generally we recommend using a flow where you’re working with friends/ids to collect up to 5000 user IDs in a single API call, then use users/lookup to turn those into user objects, 100 and a time. See [node:10362] for more information.

Even with this approach, there will be users you can’t service all data for in a single rate limit window. When that happens, either use some of your app-only auth limits as a reserve or just wait until the next window rolls over to complete collection.