I need to run a query that returns a list of users, along with data about those users. Suppose I consider one person and I want to know where all his/her followers are. This query:
http://api.twitter.com/1/followers/ids.json?screen_name={screen_name}
returns a list of user ids of the person’s followers. I can then plug each user id into this query:
http://api.twitter.com/1/users/lookup.json?user_id={user_id}
to get information about the user, including location. But that means that if the person has 1000 followers, I would have to call the second query 1000 times. It would be better to do a “join” (as it would be called in SQL), where we could ask for the followers AND their locations, and do this in one query, but I can’t see how to do this.
Is this possible? Also, when asking for user lookup, is it possible to specify that you only want one field and not the whole user record (kind of like asking for select single_field instead of select * in SQL)?
You can enumerate multiple
user_ids in query. Example:http://api.twitter.com/1/users/lookup.xml?user_id=351927492,8602462,132533067,16984020,131217651,125764179
But you capped to 100 values (names, ids) per query, so for user with 1000 followers you have to make 10 queries.
Update For 1.1 version of API correct URL would be http://api.twitter.com/1.1/users/lookup.json?user_id=351927492,8602462,132533067,16984020,131217651,125764179