latlng · Python SDK
The official Python SDK for latlng.work — fast, open-data geocoding and places API powered by OpenStreetMap + Overture Maps.
- Forward geocoding — address/place name → coordinates
- Reverse geocoding — coordinates → address
- Places nearby — POIs around a lat/lon
- Places search — full-text place search
- Autosuggest — typeahead suggestions
- Categories — browse available place types
Both sync and async clients included. httpx is the only dependency.
Installation
pip install latlng
Get an API key → dash.latlng.work
Free tier: 3,000 geocodes/day. No credit card required.
Quick Start
from latlng import LatlngClient
# Get a free API key at https://dash.latlng.work/
client = LatlngClient(api_key="latlng_xxxxx") # or omit for anonymous (rate-limited)
# Forward geocode
result = client.geocode("Eiffel Tower, Paris")
print(result.first.lat, result.first.lon)
# 48.8584 2.2945
# Reverse geocode
result = client.reverse(48.8584, 2.2945)
print(result.first.name, result.first.city)
# Eiffel Tower Paris
# Places nearby
places = client.places.nearby(lat=48.8584, lon=2.2945, radius=500)
for place in places:
print(place.name, place.category, f"{place.distance_m}m")
# Full-text place search
results = client.places.search("Louvre", lat=48.8584, lon=2.2945)
# Autosuggest (typeahead)
suggestions = client.places.autosuggest("Eiff", lat=48.858, lon=2.294)
# All place categories
categories = client.places.categories()
for cat in categories:
print(cat.category, cat.count)
Async Usage
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, radius=1000)
for place in places:
print(place.name)
asyncio.run(main())
API Reference
LatlngClient / AsyncLatlngClient
| Constructor Arg | Type | Default | Description |
|---|---|---|---|
api_key |
str | None |
None |
API key (latlng_xxxxx). Anonymous if omitted. |
base_url |
str |
https://api.latlng.work |
Override API base URL. |
timeout |
float |
10.0 |
HTTP timeout in seconds. |
Geocoding
client.geocode(query, *, limit=5, lang=None, lat=None, lon=None)
Forward geocode a query string. Returns GeocodingResponse.
| Param | Type | Description |
|---|---|---|
query |
str |
Address or place name |
limit |
int |
Max results (default 5) |
lang |
str |
Language code (e.g. "en") |
lat, lon |
float |
Bias results near this location |
client.reverse(lat, lon, *, limit=1, lang=None)
Reverse geocode coordinates. Returns GeocodingResponse.
Places
client.places.nearby(lat, lon, *, radius=1000, type=None, limit=20)
POIs near a location. Returns NearbyResponse.
client.places.search(q, *, lat=None, lon=None, type=None, country=None, limit=20)
Full-text place search. Returns SearchResponse.
client.places.autosuggest(q, *, lat=None, lon=None, limit=10)
Typeahead suggestions. Returns AutosuggestResponse.
client.places.categories()
All available place categories. Returns CategoriesResponse.
Response Models
| Model | Key Fields |
|---|---|
GeocodingResult |
lat, lon, name, city, country, postcode, state |
Place |
id, name, lat, lon, category, distance_m, country, region, locality |
Category |
category, count |
All collection responses (GeocodingResponse, NearbyResponse, etc.) support iteration with for item in response.
Exceptions
| Exception | When |
|---|---|
LatlngRateLimitError |
HTTP 429 — rate limit hit |
LatlngAuthError |
HTTP 401/403 — bad API key |
LatlngUnavailableError |
HTTP 503 — upstream down |
LatlngAPIError |
Any other non-2xx error |
from latlng import LatlngClient
from latlng.exceptions import LatlngRateLimitError
client = LatlngClient()
try:
result = client.geocode("Berlin")
except LatlngRateLimitError:
print("Rate limit hit — get a free key at https://dash.latlng.work/")
Rate Limits
| Plan | Geocode | Reverse | Places | Period |
|---|---|---|---|---|
| Anonymous | 30 | 10 | 10 | /day |
| Free | 3,000 | 300 | 500 | /day |
| Pro | 1,000,000 | 100,000 | 500,000 | /month |
| Enterprise | Unlimited | Unlimited | Unlimited | /month |
→ Get a free API key at dash.latlng.work
License
MIT
Metadata
Release files for latlng 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| latlng-0.1.0.tar.gz | 8.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| latlng-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.2 kB
Release files / latlng-0.1.0.tar.gz
| Download URL | latlng-0.1.0.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4317aa8ccd3c0a97ea6b836877f7c81e8a7235c85f34620b3c2a17d808b1b498
|
|
BLAKE2b-256 checksum How to use checksums |
049d9ee027958487f142bb31c6d8775f03f011f2e6e7fd12fa8166f10ad0000b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.5 cpython/3.14.3 HTTPX/0.28.1
|
Release files / latlng-0.1.0-py3-none-any.whl
| Download URL | latlng-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8774d819fc53fc61c89eb6102c92de995e05dc9ed03bcb08cd0260834feb7a6b
|
|
BLAKE2b-256 checksum How to use checksums |
780f9ba5ec5a9df9508bfb2483e053cda8792580eb4c080731ac6d3f2dc703e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.5 cpython/3.14.3 HTTPX/0.28.1
|
Security for latlng 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.