Description:
Geo-covid: A data dash board for the Covid 19 situation in the USA
This repo is the backend api for my geo-covid project (a data dashboard embedded as a web application).
Front-end repository can be found here
US covid data from 01-2020 -> 03-2021 period (Ref)
Their data API is available here
Here's a screen shot of the
/doc
page generated withDjangoREST
The back-end aims to
-
Simulate a data storage + API of the Covid 19 data
-
This includes
- Process the data downloaded from the source
- Load data to database
- Provide an data API for front-end to visualize
- Mongo DB
- Django
- Django REST API
- Python Script
End point local link: http://127.0.0.1:8000/
API endpoint | Description |
---|---|
/doc | Show API doc and sample usage |
Prefix: /api-covid/
API endpoint | Description |
---|---|
/date-range-reports/{year}/{month}/{day}/{day_range}/ |
Report from all states in a range of days look up by start day and day interval |
/date-reports/{year}/{month}/{day}/ |
Report from all states in a single day look up by date (year, month, day) |
/global-reports/ |
National report aka: summarized report of all states in a given day |
/polygons/ |
Polygon data of states (used for map rendering) |
/reports/ |
All reports of all states |
/start-end-date/ |
Start and end date of reports in the data |
/state-reports/{state_id}/ |
All report (all days) for a state lookup by state id (stored in report) |
/state/id/{id}/ |
Detail of a state lookup by id |
/state/init/{initials}/ |
Detail of a state lookup by initials |
/state/name/{name}/ |
Detail of a state lookup by name |
/states/ |
Detail of all states |
Example output of endpoint: Getting all reports of state with id=1
http://127.0.0.1:8000/api-covid/state-reports/1/
Requirements and Installations:
-
pip install python==3.9
-
Install packages
pip install -r requirements.txt
-
Install mongodb (ref)
-
Setup environment
cp .env.dist .env # then change needed settings
-
Push data onto your running
Mongo
databasepython /scripts/load_csv_to_database.py # or python manage.py runscript load_csv_to_database
-
Run server
python manage.py runserver
-
Access
http://127.0.0.1:8000/doc
to view endpoint api docs
/data
: raw csv data/scripts
: script to load data to database: include a.py
version and anotebook.ipynb
version to show step by step execution/us_covid_api
main project files, inside includes these main files:models.py
: Object relational mapping of database items/tableserializers.py
: Turn Object to JSON objectviews.py
: Request/Endpointurls.py
: Set endpoint URL
Created by @produdez - feel free to contact me or follow my blog on medium ❤️!