39

When I call

https://maps.googleapis.com/maps/api/place/nearbysearch/xml?location=42.9825,-81.254&radius=50000&name=Medical%22Clinic&sensor=false&key=[KEY GOES HERE]

I get a set of results with next_page_token being available

now if i do the same

https://maps.googleapis.com/maps/api/place/nearbysearch/xml?location=42.9825,-81.254&radius=50000&name=Medical%22Clinic&sensor=false&key=[KEY GOES HERE]&next_page_token=[NEXT PAGE TOKEN GOES HERE]

I get the same results as the first query not the next set of results

Martin York
  • 257,169
  • 86
  • 333
  • 562
Zoinky
  • 4,083
  • 11
  • 40
  • 78

2 Answers2

87

The parameter should be pagetoken, not "next_page_token".

Try this:

https://maps.googleapis.com/maps/api/place/nearbysearch/xml?location=42.9825,-81.254&radius=50000&name=Medical%22Clinic&sensor=false&key=[KEY GOES HERE]&pageToken=[NEXT PAGE TOKEN GOES HERE]
Khalid Taha
  • 3,183
  • 5
  • 27
  • 43
  • 3
    @Thomas Andersen can we get all results at once? – Hamzeh Soboh Jun 10 '15 at 10:03
  • @Thomas Andersen sadly no –  Apr 30 '16 at 00:48
  • 2
    How do I get the actual token? I always get 20 results and don't see the token anywhere in the response. I've tried playing with the params, looking for things like bars in 5km range of a major city, so I definitely should get more than 20 results – user841760 Sep 01 '17 at 14:45
  • 1
    @Ashish Saini Are you sure? Read Places API documentation: https://developers.google.com/places/web-service/search#PlaceSearchRequests. The parameter is `pagetoken`. – xomena May 13 '18 at 10:01
  • 1
    how to set limit more than 20 ? – Jithish P N Jan 03 '19 at 13:20
  • What possible values can be used on the `pagetoken` parameter? I cannot find any info about this. Should it be passed as an empty parameter (`&pagetoken`)? – JAT86 Feb 05 '20 at 23:52
0

At first request you must use parameters without pagetoken while the following requests only pagetoken parameters, for example:

First request

https://maps.googleapis.com/maps/api/place/nearbysearch/xml?location=42.9825,-81.254&radius=50000&name=Medical%22Clinic&sensor=false&key=[KEY GOES HERE]

Other request:

https://maps.googleapis.com/maps/api/place/nearbysearch/xml?key=[KEY GOES HERE]&pagetoken=[NEXT PAGE TOKEN GOES HERE]

In case any parameters are entered in subsequent calls in addition to pagetoken and key, in the response the status will be set to INVALID_REQUEST

  • You are right .. the problem is the parameters passed in subsequent calls .. i changed the previous comment by adding more info – Gianluigi Turla Jul 06 '17 at 13:50
  • 8
    `INVALID_REQUEST` is only returned in this case: **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.** Also setting the `pageToken` parameter will cause other parameters to be ignored. It's safe to pass other parameters along with the page token parameter. Refer to: [Accessing Additional Results](https://developers.google.com/places/web-service/search#PlaceSearchPaging) – ahmdx Aug 06 '17 at 22:09
  • Please notice that parameter "pagetoken" is case sensitive, for me "pageToken" returned also INVALID_REQUEST – undead10 Jan 23 '23 at 12:53