๐ Official Python SDK ยท Open source ยท MIT License
Geocoding for Python,
done right
The official Python client for LatLng. Forward geocoding, reverse geocoding, places search, and autosuggest โ with both sync and async support.
pip install latlng
Forward Geocoding
Address or place name โ lat/lon coordinates
Reverse Geocoding
Coordinates โ human-readable address
Places Nearby
Find POIs around any lat/lon, with radius filter
Places Search
Full-text search across millions of places
Async Support
Native asyncio client for FastAPI & aiohttp
Typed Responses
Dataclass models โ no Pydantic required
Code Examples
python ยท forward geocoding
from latlng import LatlngClient # Get your free key at dash.latlng.work client = LatlngClient(api_key="latlng_xxxxx") result = client.geocode("Eiffel Tower, Paris") print(result.first.lat, result.first.lon) # 48.8584 2.2945 # Iterate multiple results for place in client.geocode("Berlin", limit=3): print(place.name, place.country)
python ยท reverse geocoding
result = client.reverse(48.8584, 2.2945) print(result.first.name, result.first.city) # Eiffel Tower Paris
python ยท places nearby
places = client.places.nearby(lat=40.748, lon=-73.985, radius=500) for place in places: print(place.name, place.category, f"{place.distance_m}m")
python ยท async / await
import asyncio from latlng import AsyncLatlngClient async def main(): async with AsyncLatlngClient(api_key="latlng_xxxxx") as client: result = await client.geocode("Tokyo") print(result.first.lat, result.first.lon) places = await client.places.nearby(lat=35.6762, lon=139.6503) for place in places: print(place.name) asyncio.run(main())
python ยท error handling
from latlng import LatlngClient from latlng.exceptions import LatlngRateLimitError client = LatlngClient() # anonymous โ 30 geocodes/day try: result = client.geocode("New York") except LatlngRateLimitError: print("Rate limit hit โ get a free key at dash.latlng.work")
Available Methods
| Method | Description | Returns |
|---|---|---|
client.geocode(query) | Forward geocode address or place name | GeocodingResponse |
client.reverse(lat, lon) | Reverse geocode coordinates to address | GeocodingResponse |
client.places.nearby(lat, lon) | POIs near a location, with radius filter | NearbyResponse |
client.places.search(q) | Full-text place search | SearchResponse |
client.places.autosuggest(q) | Typeahead place suggestions | AutosuggestResponse |
client.places.categories() | List all available place categories | CategoriesResponse |
client.health() | Check API availability | bool |
Ready to start?
Get a free API key in seconds โ 3,000 geocoding requests per day, no credit card required.