pytidycensus.CensusAPI
- class pytidycensus.CensusAPI(api_key=None, cache_dir=None)[source]
Bases:
objectCore client for interacting with US Census Bureau APIs.
Handles authentication, rate limiting, caching, and error handling for Census API requests.
Methods
__init__([api_key, cache_dir])Initialize Census API client.
get(year, dataset, variables, geography[, ...])Make a request to the Census API.
get_geography_codes(year, dataset[, survey])Get available geography codes for a dataset.
get_variables(year, dataset[, survey])Get available variables for a dataset.
Attributes
- BASE_URL = 'https://api.census.gov/data'
- get(year, dataset, variables, geography, survey=None, show_call=False)[source]
Make a request to the Census API.
- Parameters:
- Returns:
Parsed JSON response from API
- Return type:
- Raises:
requests.RequestException – If API request fails
ValueError – If API returns error response