Registry / data / census

census

JSON →
library0.8.27pypypi✓ verified 85d ago

A Python wrapper for the US Census Bureau's API, providing simple access to ACS, Decennial Census, and other datasets. Current version 0.8.26, with yearly updates for new data years.

pip install census
INSTALL
IMPORT
SIG · CENSUS
C
census
datapythonv0.8.27
Install
2.3s avg
Import
110ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.27 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.112s · 21.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.3s · import 0.108s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Census
from census import Census
import census
Census is a class; direct import of module does not provide class.

Initialize with API key, then call endpoint methods (e.g., acs5.state) with variables and location.

from census import Census # Get your API key from https://api.census.gov/data/key_signup.html api_key = os.environ.get('CENSUS_API_KEY', '') c = Census(api_key) # Fetch ACS5 2023 data for a state result = c.acs5.state(('NAME', 'B01001_001E'), 'Illinois') print(result)
Debug
Known issues
gotchaVariable names come from Census API, not library; ensure you use valid codes (e.g., 'B01001_001E').
fix
Check Census API documentation for available variables per dataset and year.
affects: all
deprecatedSupport for ACS 1-year estimates may be dropped in future; always specify year to avoid surprises.
fix
Explicitly pass year parameter to ACS methods (e.g., .acs5.state(..., year=2023)).
affects: >=0.8.19
Errors
Common errors & fixes
NoAuthHandlerError: No API key provided
Missing or empty API key string passed to Census constructor.
fix
Set your Census API key before creating instance: c = Census('your_key_here')
census.core.CensusUnavailable: 400 Client Error: Bad Request for url
Invalid variable code, year, or geography specification.
fix
Verify variable codes and geography parameters (e.g., state FIPS code) via Census API documentation.
Upgrade
Version history
0.8.27latest on PyPI · released May 15, 2026
Audit
Dependencies
requestsrequiredHTTP calls to Census API
usoptionalFIPS code validation
Agent activity
15 hits · last 30 days
node
10
OpenAI (training)
1
Resources
census — pip install census · libregistry