Search Endpoint

https://api.geocode.earth/v1/search

The Search endpoint enables what most people think of as classic forward geocoding: converting text that represents an address or place name into coordinates.

Geocode Earth supports geocoding addresses, points of interests, streets, and numerous administrative areas such as neighborhoods, cities, counties, states (referred to as regions), countries, and continents.

To perform forward geocoding with the search endpoint, use the text parameter to specify what to search for:

curl --get https://api.geocode.earth/v1/search \
  -d api_key=<YOUR API KEY> \
  -d "text=476+5th+Avenue,+New+York,+NY+10018"
require 'net/http'
require 'json'

api_key = '<YOUR API KEY>'
query = "https://api.geocode.earth/v1/search?"\
        "api_key=#{api_key}&"\
        "text=476 5th Avenue, New York, NY 10018"
http_response = Net::HTTP.get_response(URI(query.gsub(' ', '+')))
response = JSON.parse(http_response.body)

puts response # print the entire response

puts response['features'][0]['properties']['name']      # 476 5th Avenue
puts response['features'][0]['properties']['label']     # 476 5th Avenue, New York, NY, USA
puts response['features'][0]['geometry']['coordinates'] # [ -73.981905, 40.753664 ]
const https = require('https');

const api_key = '<YOUR API KEY>';
const query = 'https://api.geocode.earth/v1/search?' +
              `api_key=${api_key}&` +
              'text=476 5th Avenue, New York, NY 10018'.replace(' ', '+');

const req = https.get(query, (res) => {
  let body = '';
  res.on('data', data => { body += data; });

  res.on('end', () => {
    const response = JSON.parse(body);
    console.log(response); // print the entire response

    console.log(response['features'][0]['properties']['name']);      // 476 5th Avenue
    console.log(response['features'][0]['properties']['label']);     // 476 5th Avenue, New York, NY, USA
    console.log(response['features'][0]['geometry']['coordinates']); // [ -73.981905, 40.753664 ]
  });
}).end();
import json
import urllib.request

api_key = '<YOUR API KEY>'
query = "https://api.geocode.earth/v1/search?" \
        "api_key="+api_key+"&"\
        "text=476 5th Avenue, New York, NY 10018".replace(' ', '+')

response = json.load(urllib.request.urlopen(query))

print(response) # print the entire response

print(response['features'][0]['properties']['name'])      # 476 5th Avenue
print(response['features'][0]['properties']['label'])     # 476 5th Avenue, New York, NY, USA
print(response['features'][0]['geometry']['coordinates']) # [ -73.981905, 40.753664 ]
Response
{
  "type": "FeatureCollection",
  "features": [{
    "type": "Feature",
    "geometry": {
      "type": "Point",
      "coordinates": [
        151.215353,
        -33.860194
      ]
    },
    "properties": {
      "layer": "address",
      "source": "openaddresses",
      "name": "2A Macquarie Street",
      "housenumber": "2A",
      "street": "Macquarie Street",
      "postalcode": "2000",
      "confidence": 1,
      "match_type": "exact",
      "accuracy": "point",
      "country": "Australia",
      "country_a": "AUS",
      "region": "New South Wales",
      "region_a": "NSW",
      "county_a": "SY",
      "locality": "Sydney",
      "label": "2A Macquarie Street, Sydney, NSW, Australia"
    }
  }]
}