Skip to content

Instantly share code, notes, and snippets.

@avicoder
Created August 31, 2018 09:32
Show Gist options
  • Save avicoder/fd7b11d7eea3a08e552ef0526330ba99 to your computer and use it in GitHub Desktop.
Save avicoder/fd7b11d7eea3a08e552ef0526330ba99 to your computer and use it in GitHub Desktop.
Check the google api key is valid or not.
import googlemaps
from datetime import datetime
gmaps = googlemaps.Client(key='Add Your Key here')
# Geocoding an address
geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')
# Look up an address with reverse geocoding
reverse_geocode_result = gmaps.reverse_geocode((40.714224, -73.961452))
# Request directions via public transit
now = datetime.now()
directions_result = gmaps.directions("Sydney Town Hall",
"Parramatta, NSW",
mode="transit",
departure_time=now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment