Get a complete list of U.S. ZIP Codes for a given city, county, or state. City, county, and state data associated with each ZIP Code are also provided.

Request Details

Example Request Url
https://geodata.cdxtech.com/api/geoziplistcity?key={key}&state={state}&county={county}&city={city}&format={format}

Description Required Default Value Example
key Authentication Key key=dd76pxfi4feydh4bz_dtrjyf6flu4-987asdjhajkd555usds28ad984yhz
state State Reference state=nj
county County Reference county=morris
city City Reference city=morristown
format Output Formatting json format=json (supported formats: json, xml, csv)

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 state = "nj";
string county = "morris";
string city = "morristown";
string format = "json";

HttpResponseMessage message = null;

using (HttpClient client = new HttpClient())
{
    client.BaseAddress = new Uri("http://geodata.cdxtech.com");

    StringBuilder url = new StringBuilder("/api/geoziplistcity?");
    url.Append("key=").Append(key);
    url.Append("&state=").Append(state);
    url.Append("&county=").Append(county);
    url.Append("&city=").Append(city);
    url.Append("&format=").Append(format);

    message = client.GetAsync(url.ToString()).Result;
}



import requests

def get_geoziplistcity(api_key, state, county, city, response_format="json"):
    """Fetch list of ZIP codes for a given state, county, and city using the API."""
    base_url = "http://geodata.cdxtech.com"
    endpoint = "/api/geoziplistcity"
    url = f"{base_url}{endpoint}"
    params = {
        "key": api_key,
        "state": state,
        "county": county,
        "city": city,
        "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}"
    state = "nj"
    county = "morris"
    city = "morristown"
    fmt = "json"
    data = get_geoziplistcity(key, state, county, city, fmt)
    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_geoziplistcity(
    api_key: &str,
    state: &str,
    county: &str,
    city: &str,
    response_format: &str,
) -> Result> {
    let client = reqwest::blocking::Client::new();
    let resp = client
        .get("http://geodata.cdxtech.com/api/geoziplistcity")
        .query(&[
            ("key", api_key),
            ("state", state),
            ("county", county),
            ("city", city),
            ("format", response_format),
        ])
        .send()?
        .error_for_status()?;
    let json: serde_json::Value = resp.json()?;
    Ok(json)
}

fn main() -> Result<(), Box> {
    let api_key = "{your-key}";
    let state = "nj";
    let county = "morris";
    let city = "morristown";
    let fmt = "json";

    match get_geoziplistcity(api_key, state, county, city, fmt) {
        Ok(data) => println!("Response JSON:\n{}", serde_json::to_string_pretty(&data)?),
        Err(err) => eprintln!("Error fetching data: {}", err),
    }

    Ok(())
}



async function getGeoZipListCity({ key, state, county, city, format = "json" }) {
    const baseUrl = "http://geodata.cdxtech.com";
    const endpoint = "/api/geoziplistcity";
    const params = new URLSearchParams({ key, state, county, city, 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 state = "nj";
    const county = "morris";
    const city = "morristown";
    const format = "json";
    try {
        const data = await getGeoZipListCity({ key, state, county, city, format });
        console.log("Response:", data);
    } catch (err) {
        console.error("Error fetching data:", err);
    }
})();



Dim key As String = "{your-key}"
Dim state As String = "nj"
Dim county As String = "morris"
Dim city As String = "morristown"
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/geoziplistcity?")
    url.Append("key=").Append(key)
    url.Append("&state=").Append(state)
    url.Append("&county=").Append(county)
    url.Append("&city=").Append(city)
    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 state As String
Dim county AS String
Dim city AS String
Dim format As String

key = "{your-key}"
state = "nj"
county = "morris"
city = "morristown"
format = "json"

Client.BaseUrl = "https://geodata.cdxtech.com/api/"

Request.Method = WebMethod.HttpGet
Request.ResponseFormat = WebFormat.Json
Request.Resource = "geoziplistcity?key={key}&state={state}&county={county}&city={city}&format={format}"
Request.AddUrlSegment "key", key
Request.AddUrlSegment "state", state
Request.AddUrlSegment "county", county
Request.AddUrlSegment "city", city
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": "GeoZipListCity"
    "url": "https://geodata.cdxtech.com/api/geoziplistcity?key={your-key}&state=nj&county=morris&city=morristown&format=json",
    "status": "Success",
    "tokenCharge": 1,
    "message": null,
    "totalResults": 3,
    "results": [{
        "zipCode": "07960",
        "city": "MORRISTOWN",
        "state": "NJ",
        "countyName": "MORRIS"
    },
    {
        "zipCode": "07962",
        "city": "MORRISTOWN",
        "state": "NJ",
        "countyName": "MORRIS"
    },
    {
        "zipCode": "07963",
        "city": "MORRISTOWN",
        "state": "NJ",
        "countyName": "MORRIS"
    }],
    "usage": {
        "used": 100,
        "remaining": 1000
    },
    "duration": 0.0499764,
    "timeStamp": "2017-02-02T14:46:38.8901666-05:00"
}



<Root>
  <Service>GeoZipListCity</Service>
  <Url>https://geodata.cdxtech.com/api/geoziplistcity?key={your-key}&state=nj&county=morris&city=morristown&format=xml</Url>
  <Status>Success</Status>
  <TokenCharge>1</TokenCharge>
  <Message />
  <TotalResults>3</TotalResults>
  <Results>
    <ZipCode>07960</ZipCode>
    <City>MORRISTOWN</City>
    <State>NJ</State>
    <CountyName>MORRIS</CountyName>
  </Results>
  <Results>
    <ZipCode>07962</ZipCode>
    <City>MORRISTOWN</City>
    <State>NJ</State>
    <CountyName>MORRIS</CountyName>
  </Results>
  <Results>
    <ZipCode>07963</ZipCode>
    <City>MORRISTOWN</City>
    <State>NJ</State>
    <CountyName>MORRIS</CountyName>
  </Results>
  <Usage>
    <Used>100</Used>
    <Remaining>1000</Remaining>
  </Usage>
  <Duration>0.056129099999999994</Duration>
  <TimeStamp>2017-02-02T14:46:43.338033-05:00</TimeStamp>
</Root>