I’m calling this endpoint:

With the following q parameter:
("per ordini inferiori a" OR "ordina subito" OR "corri a comprare" OR "scopri come possiamo seguirti" OR "scopri cosa possiamo fare per te" OR "Usa il Codice Sconto" OR "solo per oggi puoi trovare" OR "associazione onlus" OR "aperti anche la domenica" OR "aperti anche il sabato" OR "facciamo preventivi gratuiti" OR "cerchiamo personale" OR "assumiamo personale" OR "vuoi lavorare con noi?" OR "cerchiamo volontari") AND lang:it

it returns the following error:

{ statusCode: 403,
  code: 195,
  message: 'Missing or invalid url parameter.' }

This thread is the following of this unresolved thread: Missing or invalid url parameter for search/tweets - #5

AND is the invalid parameter. A space is an implicit AND, so there is no need to specify it.

Your query is also close to the max 500 character limit, and could also fail because of too many operators - in which case it might be worth splitting it up and issuing several calls using smaller queries instead.

My bad, the query that we pass through the API is the following, without any AND, and the error persists:

(("per ordini inferiori a" OR "ordina subito" OR "corri a comprare" OR "scopri come possiamo seguirti" OR "scopri cosa possiamo fare per te" OR "Usa il Codice Sconto" OR "solo per oggi puoi trovare" OR "associazione onlus" OR "aperti anche la domenica" OR "aperti anche il sabato" OR "facciamo preventivi gratuiti" OR "cerchiamo personale" OR "assumiamo personale" OR "vuoi lavorare con noi?" OR "cerchiamo volontari") lang:it) -filter:retweets

It’s 445 chars long, so the limit is not surpassed. If the limit is surpassed I would expect another kind of error message, like “query too long”.
Furthermore, what do you mean by “too many operators”? Is there a maximum number of operators for the APIs? It’s documented? I would expect another kind of error message, like “too many operators, limit is X”.

in the docs there’s:

Queries may additionally be limited by complexity.

also this might actually be it:

URL-encoded search query of 500 characters maximum

your query appears to be too long after it’s urlencoded - adding many OR parameters together often fails, and the solution is to split up the query into smaller ones:

(("per ordini inferiori a" OR "ordina subito" OR "corri a comprare") lang:it) -filter:retweets
(("scopri come possiamo seguirti" OR "scopri cosa possiamo fare per te") lang:it) -filter:retweets
...
etc

So the 500 chars limit is applied when the query it’s URL encoded? If this is true, the following query shouldn’t work, but it does!

(("ordina subito" OR "corri a comprare" OR "scopri come possiamo seguirti" OR "scopri cosa possiamo fare per te" OR "Usa il Codice Sconto" OR "solo per oggi puoi trovare" OR "associazione onlus" OR "aperti anche la domenica" OR "aperti anche il sabato" OR "facciamo preventivi gratuiti" OR "cerchiamo personale" OR "assumiamo personale" OR "vuoi lavorare con noi?" OR "cerchiamo volontari") lang:it) -filter:retweets

It’s 417 chars not encoded, 601 chars encoded.

So what is the real chars limit?
Furthermore, the error “query may additionally be limited by complexity” is the most vague message ever. What is the code behind this at Twitter? How do you calculate complexity of a query? When do you actually return error 195, when for query too long and when for query too complex?

If that’s the case then the docs might need an update - surprised the 601 character query worked!

No idea how complexity is calculated - might be a count or operators or a time limit for retrieval, either way, the best way to go is to split the query into several and combine results yourself.

1 Like

Thank you for the suggestion, but I hope someone from Twitter will clarify the situation here.

Everything Igor said is logical and I have no better answer for you.

I’m sorry but I’m afraid there are still many open questions here. Also Igor said that he was surprised to see that the 600+ chars query works correctly.
The questions where I’d like a clear answer are:

  1. What is the real chars limit?
    1a. Is the limit considering the string encoded or not?
  2. When a query is considered too complex?
  3. When the error code 195 is returned?

All these questions can be answered precisely since there is obiviously a logic behind them, it’s not random.

Up ^

Is possibile to have an exact answer on the questions above? Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.