About
Use the Coastline API
Calculate distances from coordinates, compare shoreline definitions, and retrieve the geometry behind each result.
1. Make a request
No API key is required. Send a GET request with latitude and longitude to receive all three distance measures.
https://coastline.twins.quovy.com/coastlinecurl --get 'https://coastline.twins.quovy.com/coastline/measure' \
--data-urlencode 'lat=25.7617' \
--data-urlencode 'lon=-80.1918'| Parameter | Value |
|---|---|
| lat | Required. Latitude from −90 to 90, in decimal degrees. |
| lon | Required. Longitude from −180 to 180, in decimal degrees. |
The nationwide endpoint accepts coordinates. For an address, geocode it first and use the resulting latitude and longitude. Distances are returned in miles.
2. Choose a result
Read the measure you need from results. Each measure reports whether a result is available.
| Result key | Measures to |
|---|---|
| ocean | Ocean/gulf shoreline, excluding mapped bays and inlets. |
| tidal | Coastal shoreline including bays, sounds and tidal rivers. |
| lakes | US shoreline of the five Great Lakes. |
// Run on this site, or use the full URL from your server.
const response = await fetch(
'/coastline/measure?lat=25.7617&lon=-80.1918'
);
if (!response.ok) throw new Error('Request failed: ' + response.status);
const data = await response.json();
const ocean = data.results.ocean;
if (!ocean.ok) throw new Error(ocean.error);
console.log(ocean.value.miles);
console.log(ocean.value.coastLat, ocean.value.coastLon);
if (ocean.value.note) console.log(ocean.value.note);| Response field | Meaning |
|---|---|
| property.lat / property.lon | The coordinates you measured from. |
| results.<key>.ok | true when a result is available; otherwise read error. |
| results.<key>.value.miles | Distance to the nearest eligible shoreline point, in miles. |
| results.<key>.value.coastLat / coastLon | Coordinates of that nearest shoreline point. |
| results.<key>.value.note | Optional explanation of a source or classification fallback. Keep this with the result. |
| results.<key>.error | Reason this particular measure is unavailable. Other measures may still succeed. |
The three nationwide measures cover Alaska, Hawaii and territories. A successful HTTP response can still contain an unavailable measure, such as lakes for a location far from the Great Lakes.
3. Retrieve map geometry
GET /geometry returns a GeoJSON FeatureCollection for a selected measure and map area.
curl --get 'https://coastline.twins.quovy.com/coastline/geometry' \
--data-urlencode 'measure=ocean' \
--data-urlencode 'bbox=-80.3,25.6,-80.0,25.9' \
--data-urlencode 'zoom=12'| Parameter | Value |
|---|---|
| measure | Required: ocean, tidal, or lakes. |
| bbox | Required: west,south,east,north in decimal degrees. West must be less than east; south less than north. |
| zoom | Optional, 0–22; default 12. Below 7: national overview. From 7 to below 10: regional overview. At 10+: calculation geometry. |
| boundaries | Optional: 1 includes classification boundaries for ocean at zoom 10+. Omit for shoreline only. |
GeoJSON coordinates use longitude, latitude order. Draw features with properties.eligible = true as included shoreline. Classification boundaries have kind = "boundary" and are display overlays.
The response’s detail is national, overview, or full. Large viewports automatically use a coarser detail to stay within 100,000 vertices per response. Overview geometry is simplified for display; measurements always use the full dataset. Split an area crossing the date line into two bounding boxes at ±180°.
Addresses and batches: the original API
/distance adds address lookups and batches. Its top-level distance is the ocean-facing measure; each result also carries the full measures object (ocean, tidal, lakes).
curl --get 'https://coastline.twins.quovy.com/coastline/distance' \
--data-urlencode 'address=Miami, FL'curl 'https://coastline.twins.quovy.com/coastline/distance' \
-H 'Content-Type: application/json' \
--data '{"points":[
{"lat":25.7617,"lon":-80.1918},
{"lat":37.7749,"lon":-122.4194}
]}'| Method | Accepted inputs |
|---|---|
| GET /distance | Query parameters: address, or lat and lon. Coordinates take precedence when present. |
| POST /distance | JSON: {"address":"Miami, FL"}, {"lat":25.7617,"lon":-80.1918}, {"addresses":["Miami, FL","Boston, MA"]}, or {"points":[{"lat":25.7617,"lon":-80.1918}]}. |
Batches accept 1–100 items and return { "results": [...] } in input order. Individual lookup failures appear as inline errors. Invalid address entries reject the batch.
Single results contain property, nearest_coast, distance.miles / distance.kilometers, and a measures object with the ocean, tidal and lakes results. Address results also include matched_address.
Errors, browser access and health
| HTTP status | Meaning |
|---|---|
| 400 | Invalid or missing parameters, malformed JSON, or a batch outside the 1–100 item limit. |
| 422 | The address could not be matched to a single location. |
| 502 | The upstream coastline service could not be reached. |
| 429 | The national shoreline queue is full. Retry after the Retry-After interval (1 second). |
| 503 | A required shoreline dataset is unavailable. |
| 500 | Unexpected server error. |
Request errors return { "error": "message" }. Check both the HTTP status and each measure’s ok field.
/distance and /health support cross-origin browser requests. Call /measure and /geometry from this origin or your server.
curl 'https://coastline.twins.quovy.com/coastline/health'A healthy response is { "ok": true, "shoreline_vertices": N }. This checks the local map tile dataset. Use a /measure request to exercise the distance service.