Skip to content

🦠 A simple and fast (< 200ms) API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak. It's written in python using the πŸ”₯ FastAPI framework. Supports multiple sources!

License

Notifications You must be signed in to change notification settings

NiftyBank/python-tracker-api

Repository files navigation

Coronavirus Tracker API

Provides up-to-date data about Coronavirus outbreak. Includes numbers about confirmed cases, deaths and recovered. Support multiple data-sources.

Travis build License All Contributors GitHub stars GitHub forks GitHub last commit GitHub pull requests GitHub issues Tweet

Live global stats (provided by fight-covid19/bagdes) from this API:

Covid-19 Confirmed Covid-19 Recovered Covid-19 Deaths

Available data-sources:

Currently 2 different data-sources are available to retrieve the data:

jhu data-source will be used as a default source if you don't specify a source parameter in your request.

API Reference

All endpoints are located at coronavirus-tracker-api.herokuapp.com/v2/ and are accessible via https. For instance: you can get data per location by using this URL: https://coronavirus-tracker-api.herokuapp.com/v2/locations

You can try to open the URL in your browser to further inspect the response. Or you can make this curl call on your terminal to see the prettified response:

curl https://coronavirus-tracker-api.herokuapp.com/v2/locations | json_pp

API Endpoints

Latest Endpoint

Getting latest amount of total confirmed cases, deaths, and recoveries.

GET /v2/latest

Sample response

{
  "latest": {
    "confirmed": 197146,
    "deaths": 7905,
    "recovered": 80840
  }
}

Query String Parameters

Query string parameter Description Type
source The data-source where data will be retrieved from (jhu/csbs). Default is jhu String

Locations Endpoint

Getting latest amount of total confirmed cases, deaths, and recoveries per location.

The Location Object

GET /v2/locations/:id

Path Parameters

Path parameter Required/Optional Description Type
id OPTIONAL The unique location id for which you want to call the Locations Endpoint. Integer

Example Request

GET /v2/locations/39

Sample response

{
  "location": {
    "id": 39,
    "country": "Norway",
    "country_code": "NO",
    "province": "",
    "last_updated": "2020-03-21T06:59:11.315422Z",
    "coordinates": { },
    "latest": { },
    "timelines": {
      "confirmed": {
        "latest": 1463,
        "timeline": {
          "2020-03-16T00:00:00Z": 1333,
          "2020-03-17T00:00:00Z": 1463
        }
      },
      "deaths": { },
      "recovered": { }
    }
  }
}

List of all locations

GET /v2/locations

Sample response

{
  "latest": {
    "confirmed": 272166,
    "deaths": 11299,
    "recovered": 87256
  },
  "locations": [
    {
      "id": 0,
      "country": "Thailand",
      "country_code": "TH",
      "province": "",
      "last_updated": "2020-03-21T06:59:11.315422Z",
      "coordinates": {
        "latitude": "15",
        "longitude": "101"
      },
      "latest": {
        "confirmed": 177,
        "deaths": 1,
        "recovered": 41
      }
    },
    {
      "id": 39,
      "country": "Norway",
      "country_code": "NO",
      "province": "",
      "last_updated": "2020-03-21T06:59:11.315422Z",
      "coordinates": {
        "latitude": "60.472",
        "longitude": "8.4689"
      },
      "latest": {
        "confirmed": 1463,
        "deaths": 3,
        "recovered": 1
      }
    }
  ]
}

Query String Parameters

Query string parameter Description Type
source The data-source where data will be retrieved from. Value can be: jhu/csbs. Default is jhu String
country_code The ISO (alpha-2 country_code) to the Country/Province for which you're calling the Endpoint String
timelines To set the visibility of timelines (daily tracking).Value can be: 0/1. Default is 0 Integer

Response definitions

Response Item Description Type
{latest} The total amount of confirmed cases, deaths and recoveries for all the locations Object
{latest}/confirmed The up-to-date total number of confirmed cases for all the locations within the data-source Integer
{latest}/deaths The up-to-date total amount of deaths for all the locations within the data-source Integer
{latest}/recovered The up-to-date total amount of recovered for all the locations within the data-source Integer
{locations} The collection of locations contained within the data-source Object
{location} Information that identifies a location Object
{latest} The amount of confirmed cases, deaths and recovered related to the specific location Object
{locations}/{location}/{latest}/confirmed The up-to-date number of confirmed cases related to the specific location Integer
{locations}/{location}/{latest}/deaths The up-to-date number of deaths related to the specific location Integer
{locations}/{location}/{latest}/deaths The up-to-date number of recovered related to the specific location Integer
{locations}/{location}/id The location id. This id number is assigned to the location by the data-source. Integer
{locations}/{location}/country The Country name String
{locations}/{location}/country_code The ISO (alpha-2 country_code) Country code for the location. String
{locations}/{location}/province The province where the location belongs to. (Used only for csbs data-source of US locations. Empty with jhu data-source. String
{locations}/{location}/{coordinates}/latitude The location latitude Float
{locations}/{location}/{coordinates}/longitude The location longitude Float

Example Requests with parameters

Parameter: country_code Getting data for the Country specified by the country_code parameter, in this case Italy - IT

GET /v2/locations?country_code=IT

Sample Response

{
    "latest": {
        "confirmed": 59138,
        "deaths": 5476,
        "recovered": 7024
    },
    "locations": [
        {
            "coordinates": {
                "latitude": "43",
                "longitude": "12"
            },
            "country": "Italy",
            "country_code": "IT",
            "id": 16,
            "last_updated": "2020-03-23T13:32:23.913872Z",
            "latest": {
                "confirmed": 59138,
                "deaths": 5476,
                "recovered": 7024
            },
            "province": ""
        }
    ]
}

Parameter: source Getting the data from the data-source specified by the source parameter, in this case csbs

GET /v2/locations?source=csbs

Sample Response

{
  "latest": {
    "confirmed": 7596,
    "deaths": 43,
    "recovered": 0
  },
  "locations": [
    {
      "id": 0,
      "country": "US",
      "country_code": "US",
      "province": "New York",
      "state": "New York",
      "county": "New York",
      "last_updated": "2020-03-21T14:00:00Z",
      "coordinates": {
        "latitude": 40.71455,
        "longitude": -74.00714
      },
      "latest": {
        "confirmed": 6211,
        "deaths": 43,
        "recovered": 0
      }
    },
    {
      "id": 1,
      "country": "US",
      "country_code": "US",
      "province": "New York",
      "state": "New York",
      "county": "Westchester",
      "last_updated": "2020-03-21T14:00:00Z",
      "coordinates": {
        "latitude": 41.16319759,
        "longitude": -73.7560629
      },
      "latest": {
        "confirmed": 1385,
        "deaths": 0,
        "recovered": 0
      },
    }
  ]
}

Parameter: timelines Getting the data for all the locations including the daily tracking of confirmed cases, deaths and recovered per location.

GET /v2/locations?timelines=1

Explore the response by opening the URL in your browser https://coronavirus-tracker-api.herokuapp.com/v2/locations?timelines=1 or make the following curl call on your terminal:

curl https://coronavirus-tracker-api.herokuapp.com/v2/locations?timelines=1 | json_pp

NOTE: Timelines tracking starts from day 22nd January 2020 and ends to the last available day in the data-source.

Wrappers

These are the available API wrappers created by the community. They are not necessarily maintained by any of this project's authors or contributors.

PHP

Golang

C#

Python

Java

Node.js

Ruby

Lua

Prerequisites

You will need the following things properly installed on your computer.

Installation

  • git clone https://github.com/ExpDev07/coronavirus-tracker-api.git
  • cd coronavirus-tracker-api
  • pipenv shell
  • pipenv install

Running / Development

Running Tests

  • make test

Linting

  • make lint

Building

Deploying

Contributors ✨

Thanks goes to these wonderful people (emoji key):


ExpDev

πŸ’» πŸ“– 🚧

bjarkimg

πŸ’¬

Bost

πŸ“–

GRIBOK

πŸ’» ⚠️

Oliver Thamm

πŸ“–

Mauro M.

πŸ“–

JKSenthil

πŸ’» πŸ“– ⚠️

SeanCena

πŸ’» πŸ“– ⚠️

Abdirahiim Yassin

πŸ“–

DarΓ­o HereΓ±ΓΊ

πŸ“–

Oliver

πŸ“–

License

See LICENSE.md for the license. Please link to this repo somewhere in your project :).

About

🦠 A simple and fast (< 200ms) API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak. It's written in python using the πŸ”₯ FastAPI framework. Supports multiple sources!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.9%
  • Other 1.1%