Geocode an address with Thinwrap (Python)
Resolve an address to coordinates via the Thinwrap Geocoding facade in Python — one call shape for Mapbox, Google, HERE and more.
1. Install
pip install thinwrap-location2. Send the call
import os
from thinwrap.location import Geocoding, GeocodeOptions, GoogleConfig, ConnectorError
g = Geocoding(GoogleConfig(api_key=os.environ["GOOGLE_MAPS_API_KEY"]))
try:
res = g.geocode(GeocodeOptions(
address="1600 Amphitheatre Parkway, Mountain View, CA",
country_filter=["US"],
))
for c in res.candidates:
print(c.formatted_address, c.location.lat, c.location.lng)
except ConnectorError as err:
print(f"{err.provider_code.value}: {err.provider_message}")
Same code works for all supported providers — just change the provider ID.