API
Every page is also an API. Same URL, JSON instead of HTML.
Getting JSON
You get JSON when any of these is true:
- the path ends in
.json, e.g. /51.5,-0.12.json - the request has
Accept: application/json - the user agent is
curl,Wget,HTTPieorxh
$ curl latlng.tools/51.5,-0.12/to/40.71,-74.0
{"from":[51.5,-0.12],"to":[40.71,-74],"distance_km":5571.758,...}Conventions
- Coordinates in URLs are
lat,lngin decimal degrees. In JSON, points are[lat, lng]pairs, except inside GeoJSON and bounding boxes, which are[lng, lat]and[west, south, east, north]. - Anything parseable is accepted. Browsers are redirected to the canonical URL; JSON clients get the answer straight away, with a
Link: <…>; rel="canonical"header. - Errors have a proper status (
400for input that doesn't parse,404for unknown paths) and a body like{"error": "…", "status": 400, "hint": "…"}. - Responses send
Access-Control-Allow-Origin: *, so you can call them from a browser. - Responses send
Vary: Accept, User-Agent. Most are cacheable for a day; ones that depend on the current time (local time, sun position) for a minute.
Endpoints
/:lat,:lng
A point in every format: DMS, UTM, MGRS, geohash, plus code, H3, tile, time zone and elevation.
curl 'latlng.tools/51.5074,-0.1278'Returns: lat, lng, formats{decimal, dms, ddm, utm, mgrs, geohash, pluscode, h3, tile, geojson, wkt}, utm, timezone, elevation
/:a/to/:b
Great-circle distance, bearings and midpoint.
curl 'latlng.tools/51.5074,-0.1278/to/40.7128,-74.006'Returns: from, to, distance_km, distance_mi, distance_nmi, bearing_initial, bearing_final, compass_initial, midpoint
/:point/sun
Sunrise, sunset, golden hour and twilight (add ?date=YYYY-MM-DD).
curl 'latlng.tools/51.5074,-0.1278/sun'Returns: point, date, timezone, utc_offset, times{…}, utc{…}, day_length_minutes, position
/:point/antipode
The opposite side of the Earth.
curl 'latlng.tools/51.5074,-0.1278/antipode'Returns: point, antipode
/:point/tile/:z
The slippy-map tile containing a point.
curl 'latlng.tools/51.5074,-0.1278/tile/12'Returns: tile{z, x, y}, bbox, center, quadkey, tms_y, parent, children, point
/:point/h3/:res
The H3 cell containing a point.
curl 'latlng.tools/51.5074,-0.1278/h3/7'Returns: point, cell, resolution, center, boundary, area_km2, pentagon, parent, children
/geohash/:hash
Decode a geohash: bounds, centre, neighbours.
curl 'latlng.tools/geohash/gcpvj0e'Returns: hash, precision, center, bbox, error, parent, neighbours
/tile/:z/:x/:y
Tile bounds, quadkey, parent and children.
curl 'latlng.tools/tile/12/2046/1362'Returns: tile{z, x, y}, bbox, center, quadkey, tms_y, parent, children
/h3/:cell
H3 cell boundary, area, parent and children.
curl 'latlng.tools/h3/87195da49ffffff'Returns: cell, resolution, center, boundary, area_km2, pentagon, parent, children
/pluscode/:code
Decode an Open Location Code.
curl 'latlng.tools/pluscode/9C3XGV4C+XV'Returns: code, length, bbox, center
/dms/:dms
Parse degrees, minutes and seconds, and go to the point.
curl 'latlng.tools/dms/51°30'26"N 0°7'40"W'/epsg/:code
A coordinate reference system, with a converter (?x=&y= or ?lat=&lng=).
curl 'latlng.tools/epsg/27700?lat=51.5007&lng=-0.1246'Returns: code, name, kind, units, area, bounds, proj4, source, conversion
/bbox
Draw a bounding box and copy it as [w,s,e,n], WKT, GeoJSON, Overpass and more.
GET /bbox?b=west,south,east,northReturns: bbox, center, crosses_antimeridian, area_km2, width_km, height_km, formats{…}
/polyline
Decode or encode Google / OSRM encoded polylines.
GET /polyline?p=ENCODED[&precision=6] or ?points=lat,lng;lat,lngReturns: encoded, precision, count, points, length_km, bbox
/geojson
Paste or drop GeoJSON to view, validate and fix it (winding order, precision).
curl --data-binary @file.geojson latlng.tools/geojson[?precision=6]Returns: valid, issues[{level, path, message, fix}], stats, fixed
/gpx
Drop a GPX file to see the route, distance and elevation profile.
curl --data-binary @track.gpx latlng.tools/gpx[?geojson=1]Returns: name, tracks, routes, waypoints, points, distance_km, elevation, start_time, end_time, duration_s, bbox, profile
/here
Where am I? Your location in every format.
curl 'latlng.tools/here'/random
A random point on land.
curl 'latlng.tools/random'Returns: point, path
/:point/og.png, /:a/to/:b/og.png
1200×630 PNG map previews, used for link unfurls.