The query never changes; what changes is the rectangle. Appending the city to the text (“tatuajes Madrid”) brings in the search engine's bias and makes the result depend on a phrase. Here every cell sends the same query, tatuajes, and each search is restricted with locationRestriction.rectangle to the exact perimeter of its cell. That way the coverage is complete and comparable: if a cell comes back empty, it means there are no businesses there, not that my phrase was badly written.
And this is tested. The end-to-end test intercepts the request, checks that the text sent is exactly tatuajes and that the rectangle corresponds to the cell, and then makes the assertion that matters: if I remove the pagination token, the body of the second page is identical to the first. I do not expect it to be a respected convention: it is an equality that the test breaks if anyone breaks it.
The grid is not a uniform chessboard. It is built from the Nomenclátor Geográfico de Municipios y Entidades de Población del CNIG: the national ZIP is downloaded, the program locates only the entities file (it also accepts the municipalities file or a folder, and you can drag the ZIP onto the window) and it generates an adaptive grid. It keeps population centres with a population greater than zero, avoids counting the municipality-capital-entity-centre hierarchy several times, guarantees at least one point per inhabited municipality, makes small cells where there is urban concentration and groups the rest only when they contain population. No requests are wasted covering hillside, sea or empty industrial estate.
Cost control is the part I use most in my daily work. Cells grow automatically until the worst case of three pages per cell does not exceed 4,500 calls, leaving margin against the 4,800 lockout of the plan on contract. There is a budget with a hard limit that throws an exception when it is exceeded, and note this, usage is still logged even with an unlimited budget; and the header of returned fields is trimmed to the bare minimum so that each call costs as little as possible.
National Nomenclátor ZIP → ENTIDADES.csv
→ population centres with population > 0 · hierarchy not counted twice
→ small cell in the city · grouped territorial cell in the rest
→ enlarge until 3 pages/cell ≤ 4,500 calls
→ same query “tatuajes” + locationRestriction.rectangle per cell
→ hard-limit budget · usage is always recorded