Skip to content

Geocoding

Request URL

POST /geocode

Schema

Property table for geocode

Property Description Required Schema
address Address details Yes {
  "type": "string"
}

Request Body

{
  "address": "123 Main Str, Harrisburg, PA 12345"
}

Snippet Examples

javascript

const axios = require('axios');
const data = {
  "address": "123 Main Str, Harrisburg, PA 12345"
};
const config = {
  method: 'POST',
  url: '${AMPLIFI_BASE_URL}/geocode',
  headers: {
    'Content-Type': "application/json",
    'token': "A long random string token received from /token request"
  },
  data
};

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" --data "{  \"address\":\"123 Main Str,Harrisburg,PA 12345\"}" --header "Content-Type: application/json" --header "token: A long random string token received from /token request" 

Successful Response Examples

200 GEOCODE

HEADERS

Header Value
Content-Type application/json
token A long random string token received from /token request

REQUEST BODY

{
  "address": "123 Main Str, Harrisburg, PA 12345"
}

RESPONSE BODY

{
    "success": true,
    "points":  [ {"lat": 40.7403809, "lon": -73.9897337} ] //may return a few coordinates if the address is ambiguous.
}