Skip to content

mahabub81/covid-19-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

COVID-19-API

We are using Johns Hopkins university COVID-19 git repo as source data and converting it into JSON and SQL dump. We have scripts which run periodically to update data in this repository.

Usage

Base path for COVID-19-API is https://mahabub81.github.io/covid-19-api/api/v1.

We have the following endpoints

  1. World summary (https://mahabub81.github.io/covid-19-api/api/v1/world-summary.json)
  2. World summary time series (https://mahabub81.github.io/covid-19-api/api/v1/world-summary-time-series.json)
  3. Countries and their latest update (https://mahabub81.github.io/covid-19-api/api/v1/countries.json)
  4. Time series for all countries, separate endpoint for each country by country ISO code ( Bangladesh, USA, China, India and others country )
  5. Time Series for only USA states (New York, Florida and other US states)

Javascript Code example for world summary

const fetch = require('node-fetch');  
fetch('https://mahabub81.github.io/covid-19-api/api/v1/world-summary.json')  
    .then(res => res.json())  
    .then(json => console.log(json));

output

{
  last_update: '2020-05-10 09:32:31',
  confirmed: 4040289,
  deaths: 279565,
  recovered: 1380716,
  active: 2395111
}

Example for specific country recent update

const fetch = require('node-fetch');  
fetch('https://mahabub81.github.io/covid-19-api/api/v1/countries.json')  
    .then(res => res.json())  
    .then(json => console.log(json.find(country => ( country.iso2.toLowerCase() == 'bd'))));

output

{
  uid: '50',
  iso2: 'BD',
  iso3: 'BGD',
  code3: '50',
  fips: '',
  admin2: '',
  province_state: '',
  country_region: 'Bangladesh',
  lat: '23.685',
  long_: '90.3563',
  combined_key: 'Bangladesh',
  population: '164689383',
  latest: {
    last_updated_at: '2020-05-10',
    confirmed: 14657,
    deaths: 228,
    recovered: 2650,
    active: 11779,
    incident_rate: '8.899784389865617',
    people_tested: '',
    people_hospitalized: '',
    mortality_rate: '1.5555707170635191'
  },
  states: []
}

More Example

SQL dump

MySQL and Postgres dump available, we update the dump periodically while there is an update in source repo. Dump updates are less frequent than the JSON data.

  1. MySQL
  2. Postgres

Working in SQL Example

Postman collection

Postman collection: https://documenter.getpostman.com/view/3629958/SzmfYHVh

Run in your server

To run the projects in your server clone this git repo and go to docker folder. Based on your need you can choose specific docker-compose file.

git clone https://github.com/mahabub81/covid-19-api.git 
cd ./covid-19-api/docker
# run the complete project
docker-compose up -d
#Run Only nginx comment the above line and uncomment the below line
#docker-compose  -f only-nginx.yaml up -d 
# run only the data parser```
#docker-compose  -f only-parser.yaml up -d 

Contributing

Pull requests are always welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT