Search code examples
pythongoogle-custom-search

Query length in Custom Search API


I'm sending requests to Custom Search API like this:

GOOGLE_SEARCH_URL=f'https://www.googleapis.com/customsearch/v1?key={GOOGLE_SEARCH_API_KEY}&cx={SEARCH_ENGINE_ID}&q={encoded_text}'

The text in encoded_text could be very large sometimes, and I received a 413 error. What is the length limit for this parameter?


Solution

  • From the documentation, the limit on the length of the Custom Search API request should be within 2048 characters.