The aim of this project is to normalize and centralize data from the daily reports made by the spanish government about the COVID-19 pandemic and expose them through a REST API for further analysis, like, for example, tracking the evolution of the virus along the time on each autonomous community.
Another motivation for this project is to have undistorted COVID-19 related data that can be filtered and aggregated to create more advanced charts than those shown by the media. The first thing is achieved by reading directly the reports published by the spanish government and don't rely in other third party data sources, and the second one is accomplished by exposing the data extracted from this reports through a REST API.
The dashboard is publicly avaibale at https://covid-19-spain-tracker.herokuapp.com.
The REST API is also available at https://covid-19-spain-api.herokuapp.com. You can find the documentation for the available endpoints at the end of this README.
The spanish government publish a daily report about the COVID-19 disease in a pdf format. The application runs an scraper hourly using a cron job that will try to fetch the next report. If it's available, it will parse its content and store it in MongoDB.
All of the published reports are very different between them, so you can expect
null
values for a field not present in a report.
- Cases: The number of COVID-19 confirmed cases.
- Deaths: The number of deaths due to the COVID-19 disease.
- Hospitalized: The number of people hospitalized.
- ICU: The number of people in intensive care unit.
- Recovered: The number of people who recovered from the COVID-19 disease.
All this data will be then available through the API.
You can deploy the whole application in your favorite OS using docker
and
docker-compose
.
NOTE: The application is designed to run at the free tier of Heroku, so
currently the server will run as a single service, but you can follow the next
steps to deploy it using docker-compose
.
-
Rename the
.env.template
file to.env
. -
Run:
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up --build
-
Rename the
.env.template
file to.env
. -
Run:
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build
A Postman collection is included in the repo, so you can just import it and you'll see all the available endpoints with their available query params for a more advanced filtering.
List all of the spanish autonomous communities available to use in the
autonomousCommunities
query parameter of the GET /reports
endpoint.
List all of the reports made publicly available by the government. Each report contains the values reported for each autonomous community.
-
Query parameters:
- from: Date in ISO 8601 format from which you want to retrieve the reports.
- to: Date in ISO 8601 format to which you want to retrieve the reports.
- autonomousCommunities: Comma seppared list of the autonomous communities values to be included in the report.
- sortField: String which represents the field by which we want to order the results.
- sortOrder: The order for the sorting: "asc" or "desc".
- limit: A number representing how many reports we want to retrieve. This is specially useful to retrieve the most recent report.
Get the accumulated values for the latest report available and the diff with the previous one.
COVID-19 Spain is an ElÃas GarcÃa open source project, distributed under the GNU General Public License v3.0.