Prompt
How do I get demographics data through an API?
Latest observation
Oct 8, 2026
OpenAI APIWeb search: off
To get demographics data through an API, the general process is:
-
Find a provider
- Government sources: U.S. Census API, Eurostat API, World Bank API, etc.
- Commercial sources: data vendors, marketing platforms, location intelligence APIs.
- Research/public datasets: often hosted on Socrata, CKAN, or custom endpoints.
-
Check what demographics you need Common fields include:
- Age
- Gender
- Income
- Race/ethnicity
- Education
- Household size
- Population by geography
-
Register and get an API key
- Many APIs require an account.
- You’ll usually get an API key or OAuth token for authentication.
-
Read the documentation Look for:
- Endpoint URLs
- Required parameters
- Response format (usually JSON)
- Rate limits
- Geographic levels supported (country, state, county, ZIP, census tract, etc.)
-
Make a request Example pattern:
curl "https://api.example.com/demographics?location=94107&year=2023" \ -H "Authorization: Bearer YOUR_API_KEY" -
Parse the response APIs usually return JSON, for example:
{ "location": "94107", "year": 2023, "population": 28750, "median_age": 36.4, "median_household_income": 124500 } -
Use the data carefully
- Demographics can be estimated or sampled.
- Smaller geographies may have suppressed or rounded values.
- Watch for licensing and privacy restrictions.
Example: U.S. Census API
If you want U.S. demographic data, the Census API is a common choice:
- Documentation: https://api.census.gov/data.html
- You can query population, age, income, housing, etc.
- Example request structure:
https://api.census.gov/data/2022/acs/acs5?get=NAME,B01001_001E&for=county:*&in=state:06
Example: World Bank API
For country-level demographic indicators:
- Documentation: https://datahelpdesk.worldbank.org/knowledgebase/topics/125589-developer-information
- No key required for many endpoints.
If you want, I can help you with:
- a specific API,
- example code in Python/JavaScript,
- or finding the best demographics API for your country or use case.