covid19india / api

Moved to https://github.com/covid19india/data/
https://api.covid19india.org
MIT License
678 stars 605 forks source link

Like to contribute with dynamic API's #158

Closed skavinvarnan closed 4 years ago

skavinvarnan commented 4 years ago

I already have developed a website for Covid19 called https://covidstat.info very soon to be open-sourced on Github.

Currently covidstat exposed few API's which i will attach below. Likewise i would like to process https://api.covid19india.org/raw_data.json and https://api.covid19india.org/data.json and provide dynamic queries like (statewise, district wise, town wise). Also i'm planning for graphql queries, so developers can easily filter the data.

@JunaidBabu - Need approval to do that above.

As API's will be exposed under the domain of covidstat.info and not api.covid19india.org.

https://covidstat.info/india/stats https://covidstat.info/india/allStates https://covidstat.info/india/states/{stateName} .... and so on.

Please let me know if this can go on the README document

API's

API's to directly connect and get the data on a JSON format. All Data are updated every 2 mins

Get worldwide numbers

https://covidstat.info/api/all

Get country number

https://covidstat.info/api/countries

Get particular country

https://covidstat.info/api/countries/:countryName

Example https://covidstat.info/api/countries/India

Get historic numbers

https://covidstat.info/api/historic/all

Get particular country

https://covidstat.info/api/historic/:countryName

Example https://covidstat.info/api/countries/USA

JunaidBabu commented 4 years ago

Thanks for the info. We're listing up projects depending on this repo in the Readme. Are you using the this repo to get data for your site?

Regarding the API links you provided,

  1. Where are you pulling the data from?
  2. Where are you hosting covidstat.info?
  3. If we were to shift to your API endpoints, would it be able to handle the current load of our dashboard? (usually we have around 1.5L active users on the site)
sudevschiz commented 4 years ago

Thanks for the info. We're listing up projects depending on this repo in the Readme. Are you using the this repo to get data for your site?

Added this to projects.

skavinvarnan commented 4 years ago

@JunaidBabu

Not at the moment, if you had seen my website https://covidstat.info you will find a widget for India. Planning to get data from https://api.covid19india.org/data.json

Answering your questions

  1. At present i'm processing the data from https://github.com/NovelCOVID/API as my website focuses only on global stats for now.
  2. Hosted in Digitalocean (Bangalore Datacenter), DNS proxied through Cloudflare (Los Angeles).
  3. Yes even in the current state the app can process 1000 requests per second, the app is stateless built with microservice architecture, i can easily do horizontal scale if needed, and i cache the data from NovelCovid API every 2 mins.

Quickly ran a loadtest, here are the results. 👇🏻 Loadtest setup

  1. Loadtest ran from a AWS EC2 Mumbai location
  2. covidstat.info running on Digitalocean Bangalore.
  3. covidstat.info running on a single vCPU
  4. Directly hitting IP and bypassing Cloudflare.

Results

  1. 1026 requests per second
  2. Mean latency 95.4ms
Screenshot 2020-04-22 at 11 51 26 PM
anuragsetia commented 4 years ago

@skavinvarnan humble request - do you mind fixing your World Map to display the correct India map - the one that's acceptable in India and does not exclude PoK from India boundaries? I can understand the reason why you have it the way you have it currently but...

skavinvarnan commented 4 years ago

@anuragsetia i used a library to plot the map. Probably that’s how the library works, I will definitely look into it and try overriding. Thanks for your suggestions.

skavinvarnan commented 4 years ago

@JunaidBabu Build a sample using GraphQL, going forward i will be improving this, also i will be creating REST API's, you can use it in https://www.covid19india.org/ if needed (Not at the moment, as the queries are still in alpha).

Currently i'm processing https://api.covid19india.org/data.json (only statewise) and https://api.covid19india.org/state_district_wise.json. more to follow

DEMO

open https://covidstat.info/graphql_india

Sample 1

To get statewise from data.json

query {
  all_statewise {
    active
    confirmed
    deaths
    deltaconfirmed
  }
}

Sample 2

If you need only active on statewise from data.json

query {
  all_statewise {
    statecode
    state
    active
  }
}

Sample 3

If you need statewise from data.json and also the district information for those states.

query {
  all_statewise {
    statecode
    state
    stateobj {
      districts {
        name
        active
        confirmed
        deltaconfirmed
      }
    }
  }
}

Sample 4

If you need just a specific state information along with districts information

query {
  state(statecode: "TN") {
    statecode
    districts {
      name
      confirmed
      deltaconfirmed
      deltadeceased
      deltarecovered
    }
  }
}

On top this you can use all sorts of other features provided by graphql like sorting, filtering, skipping etc...

PS: Do not add this API's and queries on the README, as its still in alpha phase and likely to change. Will let you know once queries are stabilised.

@JunaidBabu do you think this will be helpful for https://www.covid19india.org ? If yes let me know the requirements, i will developer API's or Graphql based on your specifies when i'm working on providing the API's.