Covid-19 API

The Covid-19 API provides current and historical Covid-19 data for every country in the world. Available data includes confirmed case counts and deaths, and is updated everyday.

/v1/covid19 GET

https://api.api-ninjas.com/v1/covid19

Returns either a time series of Covid-19 case counts/deaths for a country/region or a single-day snapshot of every country in the world (see parameters).


Parameters

    Either date or country must be set.

  • date  optional

    Date to retrieve single-day snapshot. Must be in the form of YYYY-MM-DD (e.g. 2022-01-01).

  • country  optional

    Country name (case insensitive).

  • region  optional

    Administrative region (also known as state or province in many countries) name (case insensitive). Must be used in conjunction with country. If not set, countries with data broken down by administrative regions will return separate data for each region.

  • county  optional

    County name for US states (case insensitive). For United States data only. Must be used in conjunction with country (United States) and region (e.g. California).

  • type  optional

    Type of data to retrieve. Must be either cases or deaths. If not set, cases will be used by default.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

country
https://api.api-ninjas.com/v1/covid19?country=canada

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 [ { "country": "Canada", "region": "Alberta", "cases": { "2020-01-22": { "total": 0, "new": 0 }, "2020-01-23": { "total": 0, "new": 0 }, "2020-01-24": { "total": 0, "new": 0 }, "2020-01-25": { "total": 0, "new": 0 }, "2020-01-26": { "total": 0, "new": 0 }, ... } }, { "country": "Canada", "region": "British Columbia", "cases": { "2020-01-22": { "total": 0, "new": 0 }, "2020-01-23": { "total": 0, "new": 0 }, "2020-01-24": { "total": 0, "new": 0 }, "2020-01-25": { "total": 0, "new": 0 }, "2020-01-26": { "total": 0, "new": 0 }, ... } }, ... ]

Code Examples

1 2 3 4 5 6 7 8 9 import requests country = 'canada' api_url = 'https://api.api-ninjas.com/v1/covid19?country={}'.format(country) response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'}) if response.status_code == requests.codes.ok: print(response.text) else: print("Error:", response.status_code, response.text)

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.