Developers

Documentation

Geoclarity turns a latitude and longitude in the United States into a structured street address with a single HTTP request. This page covers how to authenticate, make your first call and read the response.

Authentication

Every request must carry your API credentials, a username and a password, sent with HTTP Basic authentication over HTTPS. We issue credentials when we set up your account; to request them, email contact@geoclarity.net.

By default, credentials only work from the IP addresses you have registered with us. Send us the addresses of your servers when you ask for credentials, or ask us to lift the restriction.

Call the API from your server, not from a browser or a mobile app, so that your credentials stay secret.

Quickstart

Send a GET request with a latitude and a longitude, replacing USERNAME and PASSWORD with your credentials:

curl
curl -u "USERNAME:PASSWORD" \
  "https://api.geoclarity.net/api/v1/address?lat=40.7128&lon=-74.0060"
JavaScript (Node.js 18+)
const credentials = Buffer.from("USERNAME:PASSWORD").toString("base64");

const response = await fetch(
  "https://api.geoclarity.net/api/v1/address?lat=40.7128&lon=-74.0060",
  { headers: { Authorization: `Basic ${credentials}` } },
);
const data = await response.json();

console.log(data.results[0].formatted);
// New York City Hall, 260 Broadway, New York, NY 10000, United States of America
Python
import requests

response = requests.get(
    "https://api.geoclarity.net/api/v1/address",
    params={"lat": 40.7128, "lon": -74.0060},
    auth=("USERNAME", "PASSWORD"),
)
data = response.json()

print(data["results"][0]["formatted"])
# New York City Hall, 260 Broadway, New York, NY 10000, United States of America

The response is JSON. For the coordinate above it looks like this:

Response
{
  "results": [
    {
      "bounds": {
        "northeast": { "lat": 40.7130254, "lng": -74.0055687 },
        "southwest": { "lat": 40.712445, "lng": -74.0064455 }
      },
      "components": {
        "continent": "North America",
        "country": "United States of America",
        "city": "New York",
        "amenity": "New York City Hall",
        "county": "New York County",
        "postcode": "10000",
        "_type": "amenity",
        "house_number": "260",
        "ISO_3166-1_alpha-2": "US",
        "ISO_3166-1_alpha-3": "USA",
        "country_code": "us",
        "road": "Broadway",
        "neighbourhood": "Tribeca",
        "suburb": "Manhattan",
        "_category": "amenity",
        "state": "New York",
        "ISO_3166-2": ["US-NY"],
        "state_code": "NY",
        "quarter": "Lower Manhattan"
      },
      "confidence": 9,
      "distance_from_q": { "meters": 8 },
      "formatted": "New York City Hall, 260 Broadway, New York, NY 10000, United States of America",
      "geometry": { "lat": 40.7127395, "lng": -74.005939 }
    }
  ],
  "total_results": 1
}

Request

Endpoint
GET https://api.geoclarity.net/api/v1/address
ParameterRequiredDescription
latYesLatitude in decimal degrees, from -90 to 90.
lonYesLongitude in decimal degrees, from -180 to 180.

Coordinates use WGS 84, the system used by GPS. Send both parameters as decimal numbers with a period as the decimal separator.

Coverage

The API covers the United States.

Response

The matched place is returned in results, and total_results is the number of results. Each result has these fields:

FieldDescription
formattedThe full address as a single line, ready to display.
componentsThe address broken into parts, such as house number, road, city and postcode. See the list below.
geometryThe latitude and longitude of the matched place.
boundsThe bounding box of the matched place, given as its northeast and southwest corners.
distance_from_q.metersThe distance in meters between the coordinate you sent and the matched place.
confidenceHow precise the match is, from 2 to 9. See the scale below.

When nothing is found

If there is no address for the coordinate, such as a point in open ocean, the request still succeeds and the result list is empty:

Response
{
  "results": [],
  "total_results": 0
}

Confidence

confidence tells you what kind of place the coordinate was matched to. Higher is more precise.

ValueMatched to
9A building, an address or a named place
8A street
7A neighbourhood or small settlement
6A town, village or suburb
5A city
2 to 4A county, a state or a larger area

Address components

Which components are present depends on the place: a coordinate on a rural road may have no house_number, for example. Treat every component as optional.

ComponentDescription
house_number, roadThe street address.
neighbourhood, quarter, suburbAreas within the city.
city, town, village, hamletThe settlement. Only one of these is usually present.
county, state, state_code, postcodeThe county, the state with its two-letter code, and the ZIP code.
nearest_city, nearest_city_type, nearest_city_distance_kmAdded when the coordinate lies outside any city, town or village: the nearest one, what kind of settlement it is, and how far away it is in kilometers.
_type, _categoryThe kind of place that was matched. When it is a named place, its name appears under a key of that type: in the example the type is amenity, and the amenity component holds “New York City Hall”.
road_typeThe kind of road, such as residential or motorway. Present when the match is a road.
country, country_code, continent, ISO_3166-1_alpha-2, ISO_3166-1_alpha-3, ISO_3166-2The country and continent, with ISO codes for the country and the state.

Errors

The HTTP status code tells you what happened:

StatusMeaning
200Success. The result list is empty if no address was found.
400A coordinate is out of range.
401The credentials are missing or wrong.
403The credentials are valid, but the request came from an IP address that is not registered for them.
500Something went wrong on our side.
502Our geocoding backend was unavailable. Retry after a short pause.

Responses with status 400, 500 and 502 carry a JSON body with a single error message:

Error response
{
  "error": "Geocoding service unavailable"
}

Attribution and storing results

Results are derived from OpenStreetMap data. If you use the API in a publicly available product, credit OpenStreetMap, for example with “© OpenStreetMap contributors” linked to openstreetmap.org/copyright.

You may store the results and keep them for as long as you like, including after you stop using the API. The details are in our Terms and Conditions.

Free allowance and pricing

The first 100,000 requests each month are free. Beyond that, usage is billed per 1,000 requests, starting at $0.04 and falling to $0.01 at high volume. See pricing for the full table and a cost estimator.

Support

Questions about integrating the API, or something not covered here? Email contact@geoclarity.net.