datasets / covid-19

Novel Coronavirus 2019 time series data on cases
https://datahub.io/core/covid-19
1.16k stars 604 forks source link

API based on the Data Package #28

Open loleg opened 4 years ago

loleg commented 4 years ago

As a lot of people want to connect from dashboards and get filtered/streaming access to the data, it would be good to also set up an (example) wrapper with API endpoints.

See also https://github.com/Quintessential-SFT/Covid-19-API and https://github.com/dataletsch/panoptikum/blob/master/app.py

Design (from @rufuspollock)

Jobs to be done: i want to get latest data for my country / region.

url: coronavirus.api.datahub.io

Desired API

GET /country/{name or code} => (in reverse date order)
[ 
 {
  date: 
  confirmed: ...
  deaths: 
 }
]

API-ifying a Data Package

Can we take Inspiration from https://github.com/simonw/datasette

We have a datapackage.json - let's auto API-ify-it.

e.g. suppose we have a table cases.csv

Country, Date, Value

Each table => a url ...

/cases?field=x

Values => sub-urls

Dimension

Adding an id (??)

/cases/{country}/{date}
rufuspollock commented 4 years ago

@loleg this is pretty easy - can you give more details of the API structure you'd like to see?

anuveyatsu commented 4 years ago

@loleg since it is published to datahubio, it provides some API:

https://datahub.io/core/covid-19#data-cli

loleg commented 4 years ago

Point taken. I'll close this and (let someone) write an external wrapper.

rufuspollock commented 4 years ago

I'm going to re-open - the stuff at https://datahub.io/core/covid-19#data-cli is not really a fully API. Yes it has CORS and JSON but nothing more.

@loleg would love more suggestions here. I've also added more to the issue description now.

AndresMorelos commented 4 years ago

Maybe this API that I developed can make useful https://github.com/AndresMorelos/coivd-19-api.

It is published at http://ec2-18-223-118-73.us-east-2.compute.amazonaws.com/

For Countries data :

http://ec2-18-223-118-73.us-east-2.compute.amazonaws.com/countries/

## Filter by Country
http://ec2-18-223-118-73.us-east-2.compute.amazonaws.com/countries/?Country=NAME
http://ec2-18-223-118-73.us-east-2.compute.amazonaws.com/countries/?country=NAME

## Filter by Date
http://ec2-18-223-118-73.us-east-2.compute.amazonaws.com/countries/?Date=YYYY-MM-DD
http://ec2-18-223-118-73.us-east-2.compute.amazonaws.com/countries/?date=YYYY-MM-DD

## Filter by Country & Date
http://ec2-18-223-118-73.us-east-2.compute.amazonaws.com/countries/?Country=NAME&Date=YYYY-MM-DD
http://ec2-18-223-118-73.us-east-2.compute.amazonaws.com/countries/?country=NAME&date=YYYY-MM-DD
rufuspollock commented 4 years ago

@AndresMorelos great! I think the code is javascript. Would you be up for refactoring to use data package structure?