Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChicagoDev/3babd954b5ace8a12053e71b3a6367e8 to your computer and use it in GitHub Desktop.
Save ChicagoDev/3babd954b5ace8a12053e71b3a6367e8 to your computer and use it in GitHub Desktop.
import googlemaps
import json
from pprint import pprint
import time
## Import API Key
with open('config.json') as config_file:
config_data = json.load(config_file)
## Establish API Connection
gmaps = googlemaps.Client(key=config_data['maps_api_key'])
## Find places
barber_shops = gmaps.places('barber shop', radius=3218)
#Extract Next Page Token
npt = barber_shops["next_page_token"]
#For Usability
print(f'The first business returned is {barber_shops["results"][0]["name"]}')
print(f'\t The placed id is {barber_shops["results"][0]["id"]}')
print(f'\n\t\tThe next_page_token is {npt}')
#Request the next page || Raises googlemaps.exceptions.ApiError: INVALID_REQUEST
next_page_barber_shops = gmaps.places('barber shop', radius=3218, page_token=npt)
pprint(next_page_barber_shops)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment