Google Maps API displays 20 results on one page. By using page_token parameter, it is possible to get more than 20 results. The API fetches maximum 60 results for a query. The query can be refined should we need more result - run the query on sub-division level instead of country.

The following code loads the first 20 results, if the JSON file has "next_page_token" key then it recursively loads the subsequent pages.

The scripts available in my GitRepo

And here's are the saved results in Gist. Nepalese Restaurants in Europe. Interestingly, there are almost 80 Nepalese restaurants in Finland.

The script uses 3 libraries. time is needed to delay the API call. Google has a limitation on request per second.

import json
import requests
import time

The next is declare the varible and load first JSON

# Declare API Key & Query
key = 'AIzaSyXXX-XXXX'
query = 'Nepalese+Restaurants+Finland'
url = '' + str(query) + '&key=' + str(key)

# Parse JSON
jsonfile = requests.get(url)
f = jsonfile.json()

The below function recursively populates the result.

# Recursive Function
def getjson(url, pagetoken, key, query):

    time.sleep(3)  # API has requests per second limitation

    if pagetoken == '':
        print('url', url)


        print('e1url', url)

        # Reset URL
        url = '' + str(query) + '&key=' + str(key)
        url = url + '&pagetoken=' + pagetoken

        jsonfile = requests.get(url)
        f = jsonfile.json()

        # append array with desired data from JSON
        for count, name in enumerate(f['results']):

        # print(f) #DEBUG
        # Assign NEW Page Token
            pagetoken = f['next_page_token']
        except KeyError:
            pagetoken = ''

        # Recursive call
        getjson(url, pagetoken, key, query)