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/geoziplistcounty?key={key}&state={state}&county={county}&format={format}

Description Required Default Value Example
key Authentication Key key=dd76pxfi4feydh4bz_dtrjyf6flu4-987asdjhajkd555usds28ad984yhz
state State Reference state=nj
county County Reference county=morris
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 format = "json";

HttpResponseMessage message = null;

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

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

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



import requests

def get_geoziplistcounty(api_key, state, county, response_format="json"):
    """Fetch list of ZIP codes for a given state and county using the API."""
    base_url = "https://geodata.cxtech.com"
    endpoint = "/api/geoziplistcounty"
    url = f"{base_url}{endpoint}"
    params = {
        "key": api_key,
        "state": state,
        "county": county,
        "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"
    fmt = "json"
    data = get_geoziplistcounty(key, state, county, 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_geoziplistcounty(
    api_key: &str,
    state: &str,
    county: &str,
    response_format: &str,
) -> Result> {
    let client = reqwest::blocking::Client::new();
    let resp = client
        .get("https://geodata.cxtech.com/api/geoziplistcounty")
        .query(&[
            ("key", api_key),
            ("state", state),
            ("county", county),
            ("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 fmt = "json";

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

    Ok(())
}



async function getGeoZipListCounty({ key, state, county, format = "json" }) {
    const baseUrl = "https://geodata.cxtech.com";
    const endpoint = "/api/geoziplistcounty";
    const params = new URLSearchParams({ key, state, county, 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 format = "json";
    try {
        const data = await getGeoZipListCounty({ key, state, county, 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 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/geoziplistcounty?")
    url.Append("key=").Append(key)
    url.Append("&state=").Append(state)
    url.Append("&county=").Append(county)
    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 format As String

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

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

Request.Method = WebMethod.HttpGet
Request.ResponseFormat = WebFormat.Json
Request.Resource = "geoziplistcounty?key={key}&state={state}&county={county}&format={format}"
Request.AddUrlSegment "key", key
Request.AddUrlSegment "state", state
Request.AddUrlSegment "county", county
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": "GeoZipListCounty"
    "url": "https://geodata.cdxtech.com/api/geoziplistcounty?key={your-key}&state=nj&county=&format=json",
    "status": "Success",
    "tokenCharge": 10,
    "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>GeoZipListCounty</Service>
  <Url>https://geodata.cdxtech.com/api/geoziplistcounty?key={your-key}&state=nj&county=&format=xml</Url>
  <Status>Success</Status>
  <TokenCharge>10</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>