Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

desholmes/covid-19-uk-api

Repository files navigation

COVID-19 UK Data REST API

A REST API for the UK COVID-19 data gathered by tomwhite. There is also a REST API for the US COVID-19 data gathered by nytimes.

Docker Image Details

hub.docker.com/repository/docker/desholmes/covid-19-uk-api.

  • Registry: desholmes
  • Repository name: covid-19-uk-api
  • Current version: 1.0.6

Using the API

A hosted version version of the API can be found at covid-19-uk-api.dholmes.co.uk.

The following starts a local server running on port 8000:

docker run -it -p 8000:8000 desholmes/covid-19-uk-api:1.0.3
URL Description Hosted Link Local Link
/uk/totals All UK totals: tests, confirmed cases and deaths hosted local
/uk/totals/?date=2020-03-15 UK totals for date (20-03-15): tests, confirmed cases and deaths hosted local
/uk/cases Total cases by local authorities for the UK: country, area code, area and total cases hosted local
/uk/cases/?date=20-03-15 Total cases for date (20-03-15) by local authorities for the UK: country, area code, area, and total cases hosted local
/scotland/totals All Scotland totals: tests, confirmed cases and deaths hosted local
/scotland/totals/?date=20-03-15 All Scotland totals for date (2020-03-15): tests, confirmed cases and deaths hosted local
/wales/totals All Wales totals: tests, confirmed cases and deaths hosted local
/wales/totals/?date=2020-03-15 All Wales totals for date(2020-03-15): tests, confirmed cases and deaths hosted local
/northern-ireland/totals All Northern Ireland totals: tests, confirmed cases and deaths hosted local
/northern-ireland/totals/2020-03-15 All Northern Ireland totals for date (2020-03-15): tests, confirmed cases and deaths hosted local

Getting Started (Development)

Prerequisites

  1. Installation of Docker CE
  2. Installation of git SCM
  3. Knowledge of Python 3.7.3
  4. Knowledge of Django 3.0.8
  5. Knowledge of Django REST framework 3.11.0

Development takes place inside a docker container to:

  1. Remove the need for a local virtual environment
  2. Ensure the DEV environment is a close as possible to PROD

Set up

  1. Complete the 'Getting Started > Prerequisites' section
  2. By default the app is configure for local development. Running make build-cold stand your local env up from scratch (not to be used for PROD)
  3. Open 0.0.0.0:8000 in a browser to see the app running
  4. Changing files in covid_19_uk will cause the app to reload
  5. Press CTL+c to stop the docker container

If you want to configure the application step-by-step follow the steps below:

  1. Run make setup: To create the .env file from .env-dist
  2. Configure the following in .env:
    1. PORT: The port the Django server will be exposed on (default 8000)
    2. DEBUG: Enable the app to run in development mode using python3 manage.py runserver, with live reloading of files changed in covid_19_uk (default 1)
    3. DEV: Enables DEBUG for the app (default 1)
    4. QA: Enables flake8 to be run against code on initial run, not live reload (default 1)
    5. SECRET_KEY: Secret key for the app, replace add_me with a random string (default 'add_me')
  3. Run make build: To create the docker image
  4. Run make run: To run the docker image as a container
  5. Open 0.0.0.0:8000 in a browser to see the app running
  6. The 2 above commands can be run using make build-run
  7. Press CTL+c to stop the docker container

Credits

Version History

  1. 1.0.6: Added sma_7 & deaths_daily and updated to Django 3.0.7
  2. 1.0.5: Bugfix for caching
  3. 1.0.4: Added CORS allow all headers, caching, ga tracking, GNU GENERAL PUBLIC V3 LICENSE
  4. 1.0.3: Added hosted API
  5. 1.0.2: Added default port
  6. 1.0.1: Added endpoints and docs for available data sources
  7. 1.0.0: Base repo with DBless Django app