Travel

Distance Between Coordinates API

Great-circle distance between two latitude/longitude points in kilometres, miles and nautical miles, with the initial bearing.

live POST /v1/run/geo.distance $0.0002 per request ($0.20 per 1,000)

Pricing

$0.0002 per request ($0.20 per 1,000), paid from a prepaid USD wallet. The exact amount is on every response as cost_usd; max_cost_usd refuses anything higher; failed calls are refunded.

1,000 requests = $0.20 · 10,000 = $2.00 · 100,000 = $20.00

Get an API key. New API keys come with $0.10 of free credit, no card required (limited to 2 keys per network every 30 days). That covers about 500 requests of geo.distance. Then add credits (packs from $10). No subscription; failed calls are refunded.

Get a free API key Try it in the playground

Request examples

curl

curl -s -X POST https://getallapis.com/v1/run/geo.distance \
  -H "Authorization: Bearer $GETALLAPIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from_lat":48.8566,"from_lon":2.3522,"to_lat":40.7128,"to_lon":-74.006}'

Python (requests)

import os, requests

resp = requests.post(
    "https://getallapis.com/v1/run/geo.distance",
    headers={"Authorization": f"Bearer {os.environ['GETALLAPIS_API_KEY']}"},
    json={'from_lat': 48.8566, 'from_lon': 2.3522, 'to_lat': 40.7128, 'to_lon': -74.006},
    timeout=60,
)
data = resp.json()
print(data["cost_usd"], data["output"])

Python SDK (sdk/python/getallapis_client.py)

from getallapis_client import Client
client = Client()  # reads GETALLAPIS_API_KEY
result = client.run('geo.distance', {'from_lat': 48.8566, 'from_lon': 2.3522, 'to_lat': 40.7128, 'to_lon': -74.006})
print(result['cost_usd'], result['output'])

JavaScript / TypeScript (fetch, Node 18+)

const res = await fetch("https://getallapis.com/v1/run/geo.distance", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GETALLAPIS_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"from_lat": 48.8566, "from_lon": 2.3522, "to_lat": 40.7128, "to_lon": -74.006}),
});
const data = await res.json();
console.log(data.cost_usd, data.output);

CLI

getallapis run geo.distance '{"from_lat":48.8566,"from_lon":2.3522,"to_lat":40.7128,"to_lon":-74.006}'

MCP tools/call (POST /mcp)

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "run_endpoint",
    "arguments": {
      "endpoint": "geo.distance",
      "input": {
        "from_lat": 48.8566,
        "from_lon": 2.3522,
        "to_lat": 40.7128,
        "to_lon": -74.006
      }
    }
  }
}

Quote first, free: POST /v1/quote/geo.distance with the same body. Async: send Prefer: respond-async and poll the request.

Input

FieldTypeRequiredDefaultNotes
from_latnumberyesLatitude of the start
from_lonnumberyesLongitude of the start
to_latnumberyesLatitude of the destination
to_lonnumberyesLongitude of the destination

Response

A real response from this endpoint, captured 2026-11-22 with the example input above. Lists are cut to 2 items and long text is shortened here; live values change.

{
  "ok": true,
  "request_id": "req_0000000000000000",
  "endpoint": "geo.distance",
  "status": "succeeded",
  "cost_usd": 0.0002,
  "items": 1,
  "latency_ms": 0,
  "source": {
    "id": "compute",
    "name": "GetAllAPIs compute",
    "kind": "first_party",
    "demo": false
  },
  "output": {
    "kilometers": 5837.249,
    "miles": 3627.097,
    "nautical_miles": 3151.862,
    "initial_bearing_degrees": 291.8,
    "compass": "W",
    "method": "Haversine formula on a sphere of radius 6,371.0088 km; within about 0.5% of the ellipsoidal distance."
  }
}

Output fields

Returned in output of the run envelope (ok, request_id, endpoint, status, cost_usd, items, latency_ms, source, output).

FieldMeaning
kilometersDistance in km.
milesDistance in statute miles.
nautical_milesDistance in nautical miles.
initial_bearing_degreesCompass bearing at the start, 0-360.
compassEight-point compass direction.
methodHow it is computed.

Errors

HTTPerror.codeCharged?Meaning
400 / 422invalid_inputNoThe body does not match the input schema. Use the free quote call to validate first.
401unauthorizedNoMissing, revoked or wrong API key.
402insufficient_balance / spend_cap_exceededNoThe wallet or the key's spend limit does not cover the call.
429rate_limitedNoToo many requests for this key; wait for Retry-After.
503upstream_errorRefundedThe upstream failed or timed out; retry after Retry-After.

Every error has the same shape: {"ok": false, "request_id": "…", "error": {"code", "message", "retryable"}}. See errors.

Source and latency

GetAllAPIs compute (first party). Computed on our own server from the input you send; no third party is called. One upstream per endpoint; no automatic failover.

p50 0 ms · p95 0 ms (1 calls, 30 days)

Markdown reference · JSON · Playground

FAQ

How much does the Distance Between Coordinates API cost?

$0.0002 per request ($0.20 per 1,000), paid from a prepaid USD wallet. There is no subscription. The exact amount is returned as cost_usd on every response, and failed calls are refunded.

Can I try the Distance Between Coordinates API for free?

Yes. A new key comes with $0.10 of free credit, no card required, which covers about 500 requests of this endpoint. Then add credits (packs from $10). The quote call (POST /v1/quote/geo.distance) is always free.

Where does the data come from?

From GetAllAPIs compute (first party). Computed on our own server from the input you send; no third party is called. Each endpoint has one upstream; there is no automatic failover.

What is the rate limit?

120 requests per minute per API key by default; a 429 comes with Retry-After. The upstream's own limits also apply.

Can an AI agent call it?

Yes. Connect the MCP server at /mcp and call the run_endpoint tool with endpoint="geo.distance". Setup for Claude Code, Cursor and VS Code is on the integrations pages.

Related endpoints

Validate Barcode (GTIN / EAN / UPC) APICheck the check digit of an EAN-8, UPC-A, EAN-13 or GTIN-14 product barcode and normalise it to GTIN-14.Validate IBAN APICheck an IBAN's format, country length and mod-97 check digits (80 countries). Computed locally; it does not prove the account exists.Base64 Encode / Decode APIEncode UTF-8 text to Base64 or decode Base64 back to text, standard or URL-safe alphabet.Color Converter and Contrast APIConvert a colour between hex, RGB and HSL, and compute the WCAG contrast ratio against a second colour with AA/AAA verdicts.CSV to JSON APIParse CSV (RFC 4180 quoting, auto-detected delimiter) into JSON rows keyed by the header, with optional number and boolean typing.JSON to CSV APITurn an array of JSON objects into CSV with a header row; nested values are written as JSON strings and cells are quoted when needed.Timestamp Converter APIConvert a date between ISO 8601, Unix seconds and milliseconds, and show it in any IANA time zone with weekday, ISO week and UTC offset.XML to JSON APIParse well-formed XML into JSON: attributes become @name, text becomes #text, repeated elements become arrays.Public Holidays APIPublic holidays of a country for a year (100+ countries), with local names, regional scope and the next upcoming holiday.Travel Guide Page (Wikivoyage) APIFull text of a Wikivoyage destination guide: understand, get in, get around, see, do, eat, sleep, stay safe.Travel Guide Search (Wikivoyage) APISearch Wikivoyage, the free travel guide, for destinations, itineraries and travel topics.