Skip to content

Get Nearest Addresses

Request URL

GET /geocode/:lat/:lon

Description

Returns one or more addresses nearest to the given geographical coordinates. The latitude and longitude are given as path parameters.

Snippet Examples

javascript

const axios = require('axios');
const config = {
  method: 'GET',
  url: '${AMPLIFI_BASE_URL}/geocode/:lat/:lon',
  headers: {
    'token': "A long random string token received from /token request"
  },
};

let result;
try {
  result = await axios.request(config);
  if (result.status === 200) {
    console.log(JSON.stringify(result.data));
  }
} catch (err) {
  console.log({
    errCode: err.code,
    responseStatus: err.response && err.response.status,
    data: err.response && JSON.stringify(err.response.data)
  });
}

cURL

curl --location "AMPLIFI_BASE_URL/geocode/:lat/:lon"  --header "token: A long random string token received from /token request" 

Successful Response Examples

200 GEOCODE/:LAT/:LON SUCCESSFUL RESPONSE

HEADERS

Header Value
token A long random string token received from /token request

PARAMETERS

Parameter Description Value
lat [required] 44.980553
lon [required] -93.270035

REQUEST BODY

none

RESPONSE BODY

{
    "success": true,
    "dts": "Wed Oct 27 2021 16:52:52 GMT-0400", //current time
    "address": { //the nearest address
      "addressLine1": "123 Main str",
      "addressLine2": "Apt 1",
      "city": "Harrisburg",
      "state": "PA",
      "country": "US",
      "postalCode": "12345"
    }, 
    "addresses": [ {} ] // a few more alternatives if any
}