Get U.S. ZIP Code population statistics for race based on Census 2010 ZIP Code Tabulation Areas.

Request Details

Example Request Url
https://geodata.cdxtech.com/api/georace?key={key}&zipcode={zipcode}&format={format}

Description Required Default Value Example
key Authentication Key key=dd76pxfi4feydh4bz_dtrjyf6flu4-987asdjhajkd555usds28ad984yhz
zipcode Zip Code Reference zipcode=07869
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 zipcode = "07869";
string format = "json";

HttpResponseMessage message = null;

using (HttpClient client = new HttpClient())
{
    client.BaseAddress = new Uri("https://geodata.cdxtech.com");
    
    StringBuilder url = new StringBuilder("/api/georace?");
    url.Append("key=").Append(key);
    url.Append("&zipcode=").Append(zipCode);
    url.Append("&format=").Append(format);
    
    message = client.GetAsync(url.ToString()).Result;
}



import requests

def get_georace(api_key, zipcode, response_format="json"):
    """Fetch racial demographics by ZIP code using the API."""
    base_url = "https://geodata.cdxtech.com"
    endpoint = "/api/georace"
    url = f"{base_url}{endpoint}"
    params = {
        "key": api_key,
        "zipcode": zipcode,
        "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}"
    zipcode = "07869"
    fmt = "json"
    data = get_georace(key, zipcode, 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_georace(
    api_key: &str,
    zipcode: &str,
    response_format: &str,
) -> Result> {
    let client = reqwest::blocking::Client::new();
    let resp = client
        .get("https://geodata.cdxtech.com/api/georace")
        .query(&[
            ("key", api_key),
            ("zipcode", zipcode),
            ("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 zipcode = "07869";
    let fmt = "json";

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

    Ok(())
}



async function getGeorace({ key, zipcode, format = "json" }) {
    const baseUrl = "https://geodata.cdxtech.com";
    const endpoint = "/api/georace";
    const params = new URLSearchParams({ key, zipcode, 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 zipcode = "07869";
    const format = "json";
    try {
        const data = await getGeorace({ key, zipcode, format });
        console.log("Response:", data);
    } catch (err) {
        console.error("Error fetching data:", err);
    }
})();



Dim key As String = "{your-key}"
Dim zipcode As String = "07869"
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/georace?")
    url.Append("key=").Append(key)
    url.Append("&zipcode=").Append(zipCode)
    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 zipcode As String
Dim format As String

key = "{your-key}"
zipcode = "07869"
format = "json"

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

Request.Method = WebMethod.HttpGet
Request.ResponseFormat = WebFormat.Json
Request.Resource = "georace?key={key}&zipcode={zipCode}&format={format}"
Request.AddUrlSegment "key", key
Request.AddUrlSegment "zipCode", zipcode 
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": "GeoRace",
    "url": "https://geodata.cdxtech.com/api/georace?key={your-key}&zipcode=07869&format=json",
    "status": "Success",
    "tokenCharge": 1,
    "message": null,
    "totalResults": 1,
    "results": {
        "zipCode": "07869",
        "city": "RANDOLPH",
        "state": "NJ",
        "asianPopulation": 2879,
        "blackPopulation": 885,
        "indianPopulation": 75,
        "hawaiianPopulation": 14,
        "whitePopulation": 21246,
        "otherPopulation": 739,
        "remainingPopulation": 0,
        "totalPopulation": 25838,
        "asianPercentage": 11.14,
        "blackPercentage": 3.43,
        "indianPercentage": 0.29,
        "hawaiianPercentage": 0.05,
        "whitePercentage": 82.23,
        "otherPercentage": 2.86,
        "remainingPercentage": 0.0,
        "totalPercentage": 100.0
    },
    "usage": {
        "used": 100,
        "remaining": 1000
    },
    "duration": 0.0769068,
    "timeStamp": "2017-02-02T16:05:56.9710331-05:00"
}



<Root>
  <Service>GeoRace</Service>
  <Service>https://geodata.cdxtech.com/api/georace?key={your-key}&zipcode=07869&format=xml</Service>
  <Status>Success</Status>
  <TokenCharge>1</TokenCharge>
  <Message />
  <TotalResults>1</TotalResults>
  <Results>
    <ZipCode>07869</ZipCode>
    <City>RANDOLPH</City>
    <State>NJ</State>
    <AsianPopulation>2879</AsianPopulation>
    <BlackPopulation>885</BlackPopulation>
    <IndianPopulation>75</IndianPopulation>
    <HawaiianPopulation>14</HawaiianPopulation>
    <WhitePopulation>21246</WhitePopulation>
    <OtherPopulation>739</OtherPopulation>
    <RemainingPopulation>0</RemainingPopulation>
    <TotalPopulation>25838</TotalPopulation>
    <AsianPercentage>11.14</AsianPercentage>
    <BlackPercentage>3.43</BlackPercentage>
    <IndianPercentage>0.29</IndianPercentage>
    <HawaiianPercentage>0.05</HawaiianPercentage>
    <WhitePercentage>82.23</WhitePercentage>
    <OtherPercentage>2.86</OtherPercentage>
    <RemainingPercentage>0</RemainingPercentage>
    <TotalPercentage>100</TotalPercentage>
  </Results>
  <Usage>
    <Used>100</Used>
    <Remaining>1000</Remaining>
  </Usage>
  <Duration>0.0370866</Duration>
  <TimeStamp>2017-02-02T16:06:00.3410459-05:00</TimeStamp>
</Root>