CSSEGISandData / COVID-19

Novel Coronavirus (COVID-19) Cases, provided by JHU CSSE
https://systems.jhu.edu/research/public-health/ncov/
29.13k stars 18.43k forks source link

Idea: real time http rest API #124

Open natydev opened 4 years ago

natydev commented 4 years ago

It would be better to build an http REST API application (and also graphQL) for retrieve same data actually present (and often updated) in Visual Dashboard.
CSV files are actually a decent way to obtain data, but soon data and specific locations is going to increase, and so with CSV is not the optimal solution.

If other devs want to collaborate with me, I could make quickly this kind of API application using Ruby on Rails framework.

Example endpoints and structure:

GET /v1/daily/{day}

params:

example json response:

[
  {
    "iso_3166": "CN-AH",
    "province": "Anhui",
    "country": "Mainland China",
    "lat": 31.82571,
    "lon": 117.2264,
    "updated_at": "2020-02-25T08:17:05Z",
    "confirmed": 4,
    "death": 0,
    "recovered": 1
  },
  ....
  {
    "iso_3166": "SG",
    "province": null,
    "country": "Singapore",
    "lat": 1.3521,
    "lon": 103.8198,
    "updated_at": "2020-02-25T08:17:05Z",
    "confirmed": 2,
    "death": 0,
    "recovered": 0
  }
]

GET /v1/country/{code}

params:

example json response:

 {
  "iso_3166": "CN-XJ",
  "country": "Mainland China",
  "province": "Xinjiang",
  "lat": 41.11981,
  "lon": 85.17822,
  "2020-02-10": {
    "updated_at": "2020-02-10T20:17:00Z",
    "confirmed": 10,
    "death": 0,
    "recovered": 1
  },
  ...
  "2020-02-24": {
    "updated_at": "2020-02-24T23:10:05Z",
    "confirmed": 5,
    "death": 1,
    "recovered": 2
  },
  "2020-02-25": {
    "updated_at": "2020-02-25T08:17:30Z",
    "confirmed": 4,
    "death": 0,
    "recovered": 0
  }
}
blairdgeo commented 4 years ago

You can use the Esri ArcGIS Feature Services which expose the data in a Restful API. The site uses the Feature Services for data. Here are links to the services:

Deaths https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/ncov_cases/FeatureServer/0

Cases https://services1.arcgis.com/0MSEUqKaxRlEPj5g/ArcGIS/rest/services/ncov_cases/FeatureServer/1

Cases Country https://services1.arcgis.com/0MSEUqKaxRlEPj5g/ArcGIS/rest/services/ncov_cases/FeatureServer/2

You can learn more about Esri's Rest API here:

https://geoservices.github.io/ https://developers.arcgis.com/rest/

You can perform filtered queries based on data values and/or geometry/geography.

There is also a Ruby Gem that you could use to interface with Esri's Geoservices API: https://github.com/ajturner/geoservices-ruby

timweissenfels commented 4 years ago

Take a look https://github.com/nat236919/Covid2019API Maybe it already fits ur needs (It seems to have 1 day delay) @nat236919

axegon commented 4 years ago

Since I couldn't find anything similar, I made a tiny script to pull the data from this repo and stores it in JSON files. Surely you can link it to a GCP storage bucket or an AWS bucket or even github pages for that matter and automate it. I'm not entirely sure how often this repo is updated though...

nat236919 commented 4 years ago

@ChooseYourPlan Mine uses the latest data from this repository whenever this repository data is updated.

FYI, John Hopkin's dashboard reserves the newest data.

CSSEGISandData commented 4 years ago

@ChooseYourPlan Thanks for helping other uses! Btw, please correct our name in your pages as JHU CSSE, instead of JHU CCSE.

MehranDHN commented 4 years ago

It would be better to build an http REST API application (and also graphQL) for retrieve same data actually present (and often updated) in Visual Dashboard. CSV files are actually a decent way to obtain data, but soon data and specific locations is going to increase, and so with CSV is not the optimal solution.

If other devs want to collaborate with me, I could make quickly this kind of API application using Ruby on Rails framework.

Example endpoints and structure:

GET /v1/daily/{day}

params:

  • day date in ISO 8601 format (mandatory)
  • country in ISO 3166 code (optional filter)

example json response:

[
  {
    "iso_3166": "CN-AH",
    "province": "Anhui",
    "country": "Mainland China",
    "lat": 31.82571,
    "lon": 117.2264,
    "updated_at": "2020-02-25T08:17:05Z",
    "confirmed": 4,
    "death": 0,
    "recovered": 1
  },
  ....
  {
    "iso_3166": "SG",
    "province": null,
    "country": "Singapore",
    "lat": 1.3521,
    "lon": 103.8198,
    "updated_at": "2020-02-25T08:17:05Z",
    "confirmed": 2,
    "death": 0,
    "recovered": 0
  }
]

GET /v1/country/{code}

params:

  • country in ISO 3166 code (mandatory)
  • day_from date in ISO 8601 format (mandatory)
  • day_to date in ISO 8601 format (mandatory)
  • province in ISO 3166 code (optional filter)

example json response:

 {
  "iso_3166": "CN-XJ",
  "country": "Mainland China",
  "province": "Xinjiang",
  "lat": 41.11981,
  "lon": 85.17822,
  "2020-02-10": {
    "updated_at": "2020-02-10T20:17:00Z",
    "confirmed": 10,
    "death": 0,
    "recovered": 1
  },
  ...
  "2020-02-24": {
    "updated_at": "2020-02-24T23:10:05Z",
    "confirmed": 5,
    "death": 1,
    "recovered": 2
  },
  "2020-02-25": {
    "updated_at": "2020-02-25T08:17:30Z",
    "confirmed": 4,
    "death": 0,
    "recovered": 0
  }
}

Your suggestion is very useful specially for those who want to use their creativity to analyze the data . The Arc GIS Feature Services is not the same. Additionally beacause of sanctions ESRI services are not available in some countries. So far some of other implementations has the CORS restriction which generally should be handled in server side.

elitemaks commented 4 years ago

Please check this API https://github.com/axisbits/covid-api It's updated daily, you can search by country and region. Would be helpful to get any feedback

matjung commented 4 years ago

There are a few similar issue tickets around. Maybe it is an option to move this writing into the Wiki. I am still looking for a suitable query syntax https://www.micro-work.net/covid/json2.php/Swi -> Switzerland https://www.micro-work.net/covid/json2.php/Deaths.gt(100) Sample responses: [{"Province\/State":"","Country\/Region":"Switzerland","Last Update":"2020-03-11T20:00:00","Confirmed":"1139","Deaths":"11","Recovered":"4","Latitude":"46.8182","Longitude":"8.2275"}]

[{"Province\/State":"Hubei","Country\/Region":"China","Last Update":"2020-03-13T11:09:03","Confirmed":"67786","Deaths":"3062","Recovered":"51553","Latitude":"30.9756","Longitude":"112.2707"},{"Province\/State":"","Country\/Region":"Italy","Last Update":"2020-03-11T20:00:00","Confirmed":"17660","Deaths":"1266","Recovered":"1439","Latitude":"41.8719","Longitude":"12.5674"},{"Province\/State":"","Country\/Region":"Iran","Last Update":"2020-03-11T20:00:00","Confirmed":"11364","Deaths":"514","Recovered":"2959","Latitude":"32.4279","Longitude":"53.688"},{"Province\/State":"","Country\/Region":"Spain","Last Update":"2020-03-11T20:00:00","Confirmed":"5232","Deaths":"133","Recovered":"193","Latitude":"40.4637","Longitude":"-3.7492"}]