Gives you the straight-line distance between two places, in kilometres and miles. As the crow flies, not by road.
https://api.opensolr.com/solr_manager/api/geo_distanceemail and api_key of your account, as GET or POST parameters: Authentication.01 · Parameters
from, toOne of the twoOne pair. Each end is a place name, an address or lat,lon, up to 200 characters.
pairsOne of the twoUp to 25 pairs, as JSON: [{"from": "...", "to": "..."}].
countryOptionalA two-letter country code the places are in.
02 · Example
curl -s "https://api.opensolr.com/solr_manager/api/geo_distance?email=YOUR_EMAIL&api_key=YOUR_API_KEY" --data-urlencode "from=Berlin" --data-urlencode "to=48.8566,2.3522"
03 · Answer
{ "status": true, "contract_version": 1, "count": 1, "results": [ { "found": true, "from": { "query": "Berlin", "place": "Berlin", "country_code": "DE", "lat": 52.52437, "lon": 13.41053 }, "to": { "lat": 48.8566, "lon": 2.3522 }, "km": 878.1, "mi": 545.65 } ] }
results is a list, in the order of the pairs. A pair with an end not found answers found: false with msg. Values shown are an example.
04 · Errors
ERROR_NO_PLACES_SUPPLIEDHTTP 200No pair with both ends. The answer carries max_pairs.
ERROR_MAX_25_PAIRS_PER_CALLHTTP 200More than 25 pairs.
ERROR_GEO_NO_DATA, ERROR_GEO_LOOKUP_UNAVAILABLEHTTP 200In one entry: an end not found, or the lookup failed.
WRONG_API_HOSTHTTP 404Called on opensolr.com. The answer carries the right URL.
ERROR_AUTHENTICATION_FAILEDHTTP 403The email and API key do not match.
ERROR_RATE_LIMIT_PER_MINUTEHTTP 429Too many calls. Wait for the Retry-After seconds.
Each call counts once toward your per-minute and per-hour limits, whatever the number of items: Rate limits. Lookups never use the AI allowance.
05 · Related
Coordinates of an address: address_geo.
Every error code and HTTP status of the API: API errors. Calls per minute and per hour: Rate limits.