Twitter Rest API: 404 No user matches for specified terms
Asked Answered
R

2

9

Twitter allows up to 100 user ids at a time to query for user profile information. But if there is an invalid ID among those, it returns:

404 (Not Found), No user matches for specified terms

without specifying which is the bad ID and no data is returned for the rest of the users in the list. This happens if a user in the list closes their account.

Is there a way to identify the invalid ID without going through the list once again one by one (and possibly hitting the rate limit)?

Rath answered 27/8, 2015 at 21:52 Comment(0)
E
2

https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup.html

  • If a requested user is unknown, suspended, or deleted, then that user will not be returned in the results list.
  • If none of your lookup criteria can be satisfied by returning a user object, a HTTP 404 will be thrown.

From my understanding this means:

  • If you request 10 userIds and 1 of them is suspended, the request should still return 9 results
  • If you request 2 userIds and all of them are suspended, the request will return that error

I did a quick test and it seems to work as described. Could it be that all of the IDs in your request are invalid?

Erogenous answered 25/9, 2018 at 9:25 Comment(0)
N
-1

You can use puts command for printing user id on first loop and you can see your log file or console to get the user id which is invalid.

Nearly answered 1/12, 2015 at 9:33 Comment(5)
thanks, but what do you mean by "first loop"? do you suggest first checking the users one by one? i want to avoid hitting twitter once for each user in the list, as i've stated in the question.Rath
If you want to just skip the invalid user and go on with the valid you can work on exception handling.Nearly
using exception handling you will be able to skip the id with error and code with not stop. if and user id is invalidNearly
ok, sure, but i'm fetching 100 user at once, i.e. with a single query. this is the twitter limit. i am not doing it one by one. and if a user fails in that batch of 100, it does not tell which one.Rath
okay which language you are using ? can you paste your code here?Nearly

© 2022 - 2024 — McMap. All rights reserved.