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.

Base URLhttps://coastline.twins.quovy.com/coastline
Compare distances · cURL
curl --get 'https://coastline.twins.quovy.com/coastline/measure' \
  --data-urlencode 'lat=25.7617' \
  --data-urlencode 'lon=-80.1918'
ParameterValue
latRequired. Latitude from −90 to 90, in decimal degrees.
lonRequired. 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 keyMeasures to
oceanOcean/gulf shoreline, excluding mapped bays and inlets.
tidalCoastal shoreline including bays, sounds and tidal rivers.
lakesUS shoreline of the five Great Lakes.
Read the ocean-facing result · JavaScript
// 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 fieldMeaning
property.lat / property.lonThe coordinates you measured from.
results.<key>.oktrue when a result is available; otherwise read error.
results.<key>.value.milesDistance to the nearest eligible shoreline point, in miles.
results.<key>.value.coastLat / coastLonCoordinates of that nearest shoreline point.
results.<key>.value.noteOptional explanation of a source or classification fallback. Keep this with the result.
results.<key>.errorReason 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.

Get shoreline geometry · cURL
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'
ParameterValue
measureRequired: ocean, tidal, or lakes.
bboxRequired: west,south,east,north in decimal degrees. West must be less than east; south less than north.
zoomOptional, 0–22; default 12. Below 7: national overview. From 7 to below 10: regional overview. At 10+: calculation geometry.
boundariesOptional: 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).

Look up an address · cURL
curl --get 'https://coastline.twins.quovy.com/coastline/distance' \
  --data-urlencode 'address=Miami, FL'
Batch coordinates · cURL
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}
  ]}'
MethodAccepted inputs
GET /distanceQuery parameters: address, or lat and lon. Coordinates take precedence when present.
POST /distanceJSON: {"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 statusMeaning
400Invalid or missing parameters, malformed JSON, or a batch outside the 1–100 item limit.
422The address could not be matched to a single location.
502The upstream coastline service could not be reached.
429The national shoreline queue is full. Retry after the Retry-After interval (1 second).
503A required shoreline dataset is unavailable.
500Unexpected 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.

Check the map dataset · cURL
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.