Geocode (get latitude and longitude from addresses) and reverse geocode (get addresses from latitude and longitude). Data is sourced from Google Maps Platform which provide address or rooftop geocoding precision.
Request Details
Example Request Url
https://geodata.cdxtech.com/api/geocode/google?key={key}&address={address}&city={city}&state={state}&zipcode={zipcode}&country={country}&format={format}
Description | Required | Default Value | Example | |
key | Authentication Key | key=dd76pxfi4feydh4bz_dtrjyf6flu4-987asdjhajkd555usds28ad984yhz | ||
Address | Single Line Address | address=2 west hanover ave | ||
City | City | city=randolph | ||
State | State | state=nj | ||
Zip Code | Zip cpode | zipcode=18045 | ||
Country | Country | country=us | ||
format | Output Formatting | json | format=json (supported formats: json, xml) |
Coding Examples
Here are some coding examples to get you started. Please feel free to contact support if you need additional assistance.
string key = "{your-key}";
string address = "2 west hanover ave"
string city = "randolph"
string state = "nj"
string zipcode = "07869"
string country = "us"
string format = "json";
HttpResponseMessage message = null;
using (HttpClient client = new HttpClient())
{
client.BaseAddress = new Uri("https://geodata.cdxtech.com");
StringBuilder url = new StringBuilder("/api/geocode/google?");
url.Append("key=").Append(key);
url.Append("&address=").Append(address);
url.Append("&city=").Append(city);
url.Append("&state=").Append(state);
url.Append("&zipcode=").Append(zipcode);
url.Append("&country=").Append(country);
url.Append("&format=").Append(format);
message = client.GetAsync(url.ToString()).Result;
}
import requests
def get_geocode_google(api_key, address, city, state, zipcode, country, response_format="json"):
"""Fetch geocode data using Google endpoint."""
base_url = "https://geodata.cdxtech.com"
endpoint = "/api/geocode/google"
url = f"{base_url}{endpoint}"
params = {
"key": api_key,
"address": address,
"city": city,
"state": state,
"zipcode": zipcode,
"country": country,
"format": response_format,
}
response = requests.get(url, params=params)
response.raise_for_status()
try:
return response.json()
except ValueError:
return response.text
if __name__ == "__main__":
key = "{your-key}"
address = "2 west hanover ave"
city = "randolph"
state = "nj"
zipcode = "07869"
country = "us"
format = "json"
data = get_geocode_google(key, address, city, state, zipcode, country, format)
import json
if isinstance(data, (dict, list)):
print(json.dumps(data, indent=2))
else:
print(data)
// Cargo.toml
// [dependencies]
// reqwest = { version = "0.11", features = ["blocking", "json"] }
// serde = { version = "1.0", features = ["derive"] }
// serde_json = "1.0"
use std::error::Error;
fn get_geocode_google(
api_key: &str,
address: &str,
city: &str,
state: &str,
zipcode: &str,
country: &str,
response_format: &str,
) -> Result> {
let client = reqwest::blocking::Client::new();
let resp = client
.get("https://geodata.cdxtech.com/api/geocode/google")
.query(&[
("key", api_key),
("address", address),
("city", city),
("state", state),
("zipcode", zipcode),
("country", country),
("format", response_format),
])
.send()?
.error_for_status()?;
// Parse JSON response
let json: serde_json::Value = resp.json()?;
Ok(json)
}
fn main() -> Result<(), Box> {
let api_key = "{your-key}";
let address = "2 west hanover ave";
let city = "randolph";
let state = "nj";
let zipcode = "07869";
let country = "us";
let format = "json";
match get_geocode_google(api_key, address, city, state, zipcode, country, format) {
Ok(data) => println!("Response JSON:\n{}", serde_json::to_string_pretty(&data)?),
Err(err) => eprintln!("Error fetching data: {}", err),
}
Ok(())
}
async function getGeocodeGoogle({ key, address, city, state, zipcode, country, format = "json" }) {
const baseUrl = "https://geodata.cdxtech.com";
const endpoint = "/api/geocode/google";
const params = new URLSearchParams({ key, address, city, state, zipcode, country, format });
const url = `${baseUrl}${endpoint}?${params.toString()}`;
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const text = await response.text();
try {
return JSON.parse(text);
} catch {
return text;
}
}
// Example usage:
(async () => {
const key = "{your-key}";
const address = "2 west hanover ave";
const city = "randolph";
const state = "nj";
const zipcode = "07869";
const country = "us";
const format = "json";
try {
const data = await getGeocodeGoogle({ key, address, city, state, zipcode, country, format });
console.log("Response:", data);
} catch (err) {
console.error("Error fetching data:", err);
}
})();
Dim key As String = "{your-key}"
Dim address As String = "2 west hanover ave"
Dim city As String = "randolph"
Dim state As String = "nj"
Dim zipcode As String = "07869"
Dim country As String = "us"
Dim format As String = "json"
Dim message As HttpResponseMessage = Nothing
Using client As New HttpClient()
client.BaseAddress = New Uri("https://geodata.cdxtech.com")
Dim url As New StringBuilder("/api/geocode/google?")
url.Append("key=").Append(key)
url.Append("&address=").Append(address)
url.Append("&city=").Append(city)
url.Append("&state=").Append(state)
url.Append("&zipcode=").Append(zipcode)
url.Append("&country=").Append(country)
url.Append("&format=").Append(format)
message = client.GetAsync(url.ToString()).Result
End Using
The following is for the VBA-WEB Excel template available at http://vba-tools.github.io/VBA-Web/
Dim Client As New WebClient
Dim Request As New WebRequest
Dim key As String
Dim address As String
Dim city As String
Dim state As String
Dim zipcode As String
Dim country As String
Dim format As String
key = "{your-key}"
latitude = "2 west hanover ave, randolph, nj"
format = "json"
Client.BaseUrl = "https://geodata.cdxtech.com/api/"
Request.Method = WebMethod.HttpGet
Request.ResponseFormat = WebFormat.Json
Request.Resource = "geocode/google?key={key}&address={address}&city={city}&state={state}&zipcode={zipcode}&country={country}&format={format}"
Request.AddUrlSegment "key", key
Request.AddUrlSegment "address", address
Request.AddUrlSegment "city", city
Request.AddUrlSegment "state", state
Request.AddUrlSegment "zipcode", zipcode
Request.AddUrlSegment "country", country
Request.AddUrlSegment "format", format
Set Response = Client.Execute(Request)
Output Examples
Here are some output data examples. You can also use the Report Generator tab to export specific data files.
{
"service": "GeocodeHERE",
"url": "https://geodata.cdxtech.com/api/geocode/google?address=2%20west%20hanover%20ave&city=randolph&state=nj&zipcode=07869&country=us&key={your-key}",
"status": "Success",
"tokenCharge": 1,
"message": null,
"totalResults": 1,
"results": {
"bestMatch": "2 W Hanover Ave, Randolph, NJ 07869-4212, United States",
"latitude": "40.82653",
"longitude": "-74.56786",
"street": "2 W Hanover Ave",
"city": "Randolph",
"state": "New Jersey",
"zip": "07869-4212",
"county": "Morris",
"district": null,
"country": "United States",
"confidence": "1"
},
"usage": {
"used": 10207,
"usedPercentage": 5.377964414,
"remaining": 189793,
"remainingPercentage": 94.622035586
},
"duration": 2.7948234,
"timeStamp": "2020-07-30T09:45:35.2638105-04:00"
}
<Root>
<Service>GeocodeHERE</Service>
<Url>https://geodata.cdxtech.com/api/geocode/google?address=2%20west%20hanover%20ave&city=randolph&state=nj&zipcode=07869&country=us&key={your-key}&format=xml</Url>
<Status>Success</Status>
<TokenCharge>1</TokenCharge>
<Message />
<TotalResults>1</TotalResults>
<Results>
<BestMatch>2 W Hanover Ave, Randolph, NJ 07869-4212, United States</BestMatch>
<Latitude>40.82653</Latitude>
<Longitude>-74.56786</Longitude>
<Street>2 W Hanover Ave</Street>
<City>Randolph</City>
<State>New Jersey</State>
<Zip>07869-4212</Zip>
<County>Morris</County>
<District />
<Country>United States</Country>
<Confidence>1</Confidence>
</Results>
<Usage>
<Used>10251</Used>
<UsedPercentage>5.402400013</UsedPercentage>
<Remaining>189749</Remaining>
<RemainingPercentage>94.597599987</RemainingPercentage>
</Usage>
<Duration>4.286168</Duration>
<TimeStamp>2020-07-30T14:23:57.9960396-04:00</TimeStamp>
</Root>