https://github.com/blakley/census-api
Custom built API for various US 2020 Census data
https://github.com/blakley/census-api
flask-api python selenium-python us-census
Last synced: about 1 year ago
JSON representation
Custom built API for various US 2020 Census data
- Host: GitHub
- URL: https://github.com/blakley/census-api
- Owner: Blakley
- Created: 2021-08-29T01:40:05.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-08-31T21:01:55.000Z (almost 5 years ago)
- Last Synced: 2025-02-01T04:27:33.398Z (over 1 year ago)
- Topics: flask-api, python, selenium-python, us-census
- Language: Python
- Homepage:
- Size: 5.88 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# United States 2020 Census API
An unofficial API for various US 2020 Census data

## File Information
`census.py`
Created a [selenium](https://selenium-python.readthedocs.io/) webscraper using the usa 2020 census from [census.gov](census.gov/data)
`census_dictionary.py`
A python dictionary of the extracted census values for each state
`server.py`
Created a local API on `localhost:5000` for accessing the data for each state
`states.py`
A list of urls for each state on [census.gov](census.gov/data)
`xpaths.py`
xpath values for various elements used for accessing data on the census webpage
## Routes
API routes where `name` is the name of a state.
Note: the first letter must be capitalized. Example: Alabama
* return all the data for the state: `/state?=name`
* get an overview of data for the state `/overview?=name`
* get the population data for the state `/population?=name`
* get the income data for the state `/income?=name`
* get the education data for the state `/education?=name`
* get the employment data for the state `/employment?=name`
* get the housing data for the state `/housing?=name`
* get the health data for the state `/health?=name`
* get the economy data for the state `/economy?=name`
* get the family data for the state `/family?=name`
* get the race data for the state `/race?=name`
## Dependencies
Download [ChromeDriver](https://chromedriver.chromium.org/downloads) and replace chromedriver.exe with the version that matches your chrome version
install the following using pip
```
$ pip install selenium
$ pip install flask
$ pip install pprintpp
```
## Deployment
To test out the webscraper run the following
```
$ python census.py
```
To simply use the API run the following
```
$ python server.py
```
## TODO
* put the datasets into a csv file format