Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Google Maps Platform Web Services from Python with Google’s community-supported googlemaps client or by sending HTTPS requests directly. For a typical server-side application, create a Google Cloud project, attach a billing account, enable only the APIs you need, create and restrict an API key, keep it private, then call the service from Python. This guide walks through that setup and shows geocoding and directions examples.

What “Google Maps API” means in a Python project

Google Maps Platform is a collection of services, not one API that handles every location task. A Python program typically calls a web service to geocode an address, retrieve directions, search for places, or perform another specific operation. The response is data your application can use; calling a web service does not by itself display an interactive map in a Python program.

For web-service calls, choose between the googlemaps Python client and direct HTTPS requests. The client provides Python methods for many services and handles some request mechanics. Direct requests can be useful when you need precise control over the HTTP exchange or the client does not yet cover the API version or request shape you need. Either way, Google requires an API key or client ID for each web-service request, and use of Google Maps Platform requires a billing account.

Do not assume a Python package method name or older service endpoint is the right interface for every current Google Maps product. Check the current reference for the particular service before building against it, especially for Places API (New) and other services whose request formats differ from older endpoints.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Set up the project, APIs, and key

  1. Select or create a Google Cloud project. Attach a billing account to the project before making Google Maps Platform requests.
  2. Enable the services the application will call. For example, geocoding needs the Geocoding API; routing needs the relevant directions service; place search needs Places. Address Validation, Elevation, Roads, Time Zone, Geolocation, and Maps Static are separate choices. Enable only what the workflow requires.
  3. Create an API key. In Google Cloud Console, open APIs & Services > Credentials and create a key for this workload.
  4. Restrict the key. Apply API restrictions so the key can call only the enabled services the application needs. Apply application restrictions appropriate to the server-side environment where possible. Revisit restrictions when deployment architecture changes.
  5. Store the key outside source code. Use an environment variable or secret manager. Do not commit it to a repository, embed it in a browser bundle, or expose it in a publicly accessible client application.
  6. Install the Python client if you plan to use it. Run pip install -U googlemaps in the environment used by your application.

Restrictions reduce the damage a leaked key can cause, but they are not a substitute for keeping it secret. If a key is exposed, restrict or rotate it and review its usage in Cloud Console.

Geocode an address and request directions

This example uses the Python client for two common tasks: turning an address into geocoding results and requesting transit directions. It reads the API key from the environment rather than placing a secret in the file.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
import os
from datetime import datetime

import googlemaps

api_key = os.environ["GOOGLE_MAPS_API_KEY"]
gmaps = googlemaps.Client(key=api_key)

geocode_result = gmaps.geocode(
    "1600 Amphitheatre Parkway, Mountain View, CA"
)

if geocode_result:
    first_result = geocode_result[0]
    location = first_result["geometry"]["location"]
    print("Formatted address:", first_result["formatted_address"])
    print("Coordinates:", location["lat"], location["lng"])
else:
    print("No geocoding results")

directions_result = gmaps.directions(
    "Sydney Town Hall",
    "Parramatta, NSW",
    mode="transit",
    departure_time=datetime.now(),
)

if directions_result:
    route = directions_result[0]
    print("Route summary:", route.get("summary"))
else:
    print("No directions results")

Set the variable before running the script. For example, in a Unix-like shell, run export GOOGLE_MAPS_API_KEY="your-key-value" in the same shell session, then start Python from that session. Avoid putting a real key into shell history or shared logs; a secret manager is generally a better fit for deployed applications.

The example follows the client repository’s geocoding and transit-directions pattern. It checks whether each result collection is empty before indexing it. Production code should also handle request errors, timeouts, retries, and changes or omissions in response fields before saving results or making decisions from them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Choose the service that matches the location task

Need Service category Implementation note
Convert an address to coordinates, or coordinates to an address Geocoding / reverse geocoding Inspect the returned results; an address need not produce exactly one match.
Get a route between places Directions Choose the travel mode and any supported timing or routing options required by the current service.
Compare travel time or distance across origin-destination pairs Distance Matrix Account for the service’s applicable quota unit and expected volume when designing batches.
Find places or retrieve place information Places For Places API (New), use field masks and request only the fields the application needs.
Check or standardize a postal address Address Validation Confirm availability and request requirements for the relevant address geography.
Other location workflows Elevation, Roads, Time Zone, Geolocation, or Maps Static Enable the particular service only when the application needs its specialized data.

For Places API (New), a field mask identifies the fields to return for operations such as Place Details, Nearby Search, and Text Search. Requesting only needed fields can reduce latency and billing-related usage. Design the mask around actual application requirements rather than requesting every available field by default.

Use the client or call HTTPS directly?

The googlemaps package is a community-supported client library that brings Google Maps Platform Web Services to Python. It provides service-oriented methods and avoids writing every HTTP request by hand. It is not the same thing as a promise that all future API changes will be handled under Google’s standard deprecation policy or support agreement: the library documentation explicitly says the community libraries are not covered by those terms.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Direct HTTPS requests give the application more control over headers, timeouts, retries, logging, and response processing. They also leave more implementation work to you, including choosing the correct current endpoint, constructing the service-specific request, handling HTTP and API errors, and parsing the response. Do not copy a legacy URL or request schema into a new application without checking the current service reference. Each service has its own request format and may have version-specific requirements.

For either approach, compare the API version being called, authentication handling, timeout and retry behavior, response validation, observability, and dependency-maintenance burden. Pin the package version in production, review release notes, and test when Google announces endpoint or version changes. Treat responses as external input: validate fields and types instead of assuming every request returns a complete result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Billing, quotas, and cost control

Google’s Maps Platform FAQ says a billing account is required to use Maps Platform products and that requests must include a valid API key. Do not assume a universal free tier or a fixed per-request price: pricing and included credits can change. Check the current pricing information for each service and region before estimating a bill.

Google describes usage limits generally in queries per minute (QPM), while some products use other units. Set project quotas and monitor usage in Cloud Console. The 30,000 QPM figure sometimes shown for Maps JavaScript API Dynamic Maps is specific to that product; it is not a general limit for Python web services. Use the quota shown for the exact API and project rather than extrapolating from another product.

  • Enable only the services the application actually calls.
  • Set appropriate quota controls and monitor consumption in Cloud Console.
  • For Places API (New), use field masks to request only required fields.
  • Estimate costs using the current pricing page and the expected request pattern for the specific service.
  • Handle quota and billing errors explicitly so an application does not silently treat missing data as a valid result.

Reliability and troubleshooting

Google Maps calls depend on network access, project configuration, valid credentials, quotas, and the availability of the specific service. A successful package installation does not prove that the cloud project is configured correctly. Log enough request context to diagnose failures, but redact keys and sensitive address or location data from logs.

Symptom Likely cause What to check
Authentication or permission error The key is absent, invalid, restricted for a different application, or not permitted for the service. Confirm the environment variable is present in the running process, inspect key restrictions, and verify the required API is enabled in the same project.
Billing-related request failure The project has no attached billing account or its billing configuration is not active. Check the project’s billing setup in Cloud Console.
Request rejected for an API that appears enabled The key may be restricted to a different API, or the code may be using a different or legacy service interface than intended. Compare the enabled API, key restrictions, and request shape with the current reference for that service.
Empty results The query may not match a result, or the response may legitimately contain no routes or addresses. Check for an empty result before indexing; test the input and inspect the service’s returned status and response fields.
Unexpected missing field or parsing exception Responses can vary by result and request; code may assume a field is always present. Validate response structure and use guarded field access before persisting or using values.
Slow calls or intermittent failures Network latency, service behavior, or lack of explicit timeout and retry policy may be involved. Set and test sensible timeouts and bounded retries for the chosen request method; record redacted diagnostics.
Unexpected usage or quota pressure Request volume, service units, or requested fields may differ from the estimate. Review usage by API in Cloud Console, adjust quotas, and reduce unnecessary calls or Places fields.

Or skip the browser setup

Google Maps API calls and website screenshots solve different problems: this guide uses Python to retrieve mapping data, while a screenshot API captures a rendered web page. If your task is to capture pages rather than query map data, ScreenshotNeo offers a one-call screenshot API. Its cookie/consent banner handling, newsletter popup removal, and chat-widget removal can each be turned off; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. It also has an MCP server with tools for AI agents, including Claude, Cursor, and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Example using cURL; see the ScreenshotNeo API documentation for the available request options:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo includes 1,000 screenshots a month on its free plan with no card required; paid plans start at $5 for 3,000 screenshots. Sign up for ScreenshotNeo’s free plan.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.