Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paging on Google Places API returns status INVALID_REQUEST

I'm using the Google Place API for place search:

https://developers.google.com/places/documentation/search

After the first query of the api, I'm getting the next page by setting the pagetoken. If I wait 2 seconds between requests, it works, but I notice that if I make the next query right after the previous one, it returns the status INVALID_REQUEST.

Is this some kind of rate limiting? I don't see this anywhere in the documentation.

https://developers.google.com/places/usage

Since each request has 20 places, getting a list of 100 results will take over 10 seconds which is a long time for someone to wait using an app.

like image 639
Tom Kincaid Avatar asked Jan 21 '14 18:01

Tom Kincaid


People also ask

Can you store Google Places API data?

Note that the place ID, used to uniquely identify a place, is exempt from the caching restriction. You can therefore store place ID values indefinitely.

How do I get my city name in Google Places API?

You can not normally retrieve city name from the Place, but you can easily get it in this way: 1) Get coordinates from your Place (or however you get them); 2) Use Geocoder to retrieve city by coordinates.


1 Answers

It is documented, see the documentation

By default, each Nearby Search or Text Search returns up to 20 establishment results per query; however, each search can return as many as 60 results, split across three pages. If your search will return more than 20, then the search response will include an additional value — next_page_token. Pass the value of the next_page_token to the pagetoken parameter of a new search to see the next set of results. If the next_page_token is null, or is not returned, then there are no further results. There is a short delay between when a next_page_token is issued, and when it will become valid. Requesting the next page before it is available will return an INVALID_REQUEST response. Retrying the request with the same next_page_token will return the next page of results.

like image 97
geocodezip Avatar answered Sep 30 '22 09:09

geocodezip