From 2a0109f7e8e82ce6f3129951cf25a3f057a3f1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20V=C3=A4limaa?= Date: Thu, 15 Oct 2026 14:39:23 +0800 Subject: [PATCH] docs: load the README API key from the environment --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b0e461b..d125190 100644 --- a/README.md +++ b/README.md @@ -69,13 +69,23 @@ Note that you will need requests 2.4.0 or higher if you want to specify connect/ ## Usage +Set the `GOOGLE_MAPS_API_KEY` environment variable before running the example, +replacing the placeholder with your API key: + +```bash +export GOOGLE_MAPS_API_KEY="YOUR_API_KEY" +``` + +Keep real API keys out of source control, including scripts and configuration files. + This example uses the Geocoding API and the Directions API with an API key: ```python +import os import googlemaps from datetime import datetime -gmaps = googlemaps.Client(key='Add Your Key here') +gmaps = googlemaps.Client(key=os.environ["GOOGLE_MAPS_API_KEY"]) # Geocoding an address geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')