Using the https://api.twitter.com/1.1/search/tweets.json endpoint in postman with the following query as q:

immigrant OR immigration OR migration OR migrant OR migrant worker OR immigrant worker OR immigrant labor OR migrant labor OR foreigners OR foreign-born OR non-citizens OR labor migration OR foreign-born citizens OR resident alien -filter:retweets

but am not getting responses to this. Removing labor migration, foreign-born citizens, and resident alien works, resulting in the following query:

immigrant OR immigration OR migration OR migrant OR migrant worker OR immigrant worker OR immigrant labor OR migrant labor OR foreigners OR foreign-born OR non-citizens -filter:retweets

I’m not sure why there’s a difference and would like to retain the original query. Many thanks.

I’m guessing this is due to the complexity (length) of the query.

Queries can be limited due to complexity. If this happens, the Search API will respond with the error: {“error”:“Sorry, your query is too complex. Please reduce complexity and try again.”}.

I’ll be honest, I haven’t always seen this error but I have seen blank results with long queries on the legacy v1.1 search API. It is a very old tech stack.

Have you tried a similar search on the Twittwr Developer Labs recent search API?

Thanks @andypiper! I don’t think it’s due to the length of the query though, because this returns results:

immigrant OR immigration OR migration OR migrant OR migrant worker OR immigrant worker OR immigrant labor OR migrant labor OR foreigners OR foreign-born OR non-citizens OR dogs OR cats OR penguins OR walruses OR elephants OR birds OR manatees -filter:retweets

and has 259 chars and has more keywords/operators.

We’re planning to buy a premium account to access tweets within a specified date range – is labs available with dated info? I think currently it’s just recent tweets.

Thanks!

Also, here’s the response:

{
    "statuses": [],
    "search_metadata": {
        "completed_in": 0.042,
        "max_id": 1258224638439550976,
        "max_id_str": "1258224638439550976",
        "query": "immigrant+OR+immigration+OR+migration+OR+migrant+OR+migrant+worker+OR+immigrant+worker+OR+immigrant+labor+OR+migrant+labor+OR+foreigners+OR+foreign-born+OR+non-citizens+OR+labor+migration+OR+foreign-born+citizens+OR+resident+alien+-filter%3Aretweets",
        "refresh_url": "?since_id=1258224638439550976&q=immigrant%20OR%20immigration%20OR%20migration%20OR%20migrant%20OR%20migrant%20worker%20OR%20immigrant%20worker%20OR%20immigrant%20labor%20OR%20migrant%20labor%20OR%20foreigners%20OR%20foreign-born%20OR%20non-citizens%20OR%20labor%20migration%20OR%20foreign-born%20citizens%20OR%20resident%20alien%20-filter%3Aretweets&include_entities=1",
        "count": 15,
        "since_id": 0,
        "since_id_str": "0"
    }
}

With a 200 exit code as well. FYI

hey @chanlawrencet can you try:

immigrant OR immigration OR migration OR migrant OR (migrant worker) OR (immigrant worker) OR (immigrant labor) OR (migrant labor) OR foreigners OR foreign-born OR non-citizens OR (labor migration) OR (foreign-born citizens) OR (resident alien) -filter:retweets
1 Like

@suhemparack Brilliant! Works. Thanks a bunch for your help.