pomber / covid19

JSON time-series of coronavirus cases (confirmed, deaths and recovered) per country - updated daily
https://pomber.github.io/covid19/timeseries.json
1.23k stars 375 forks source link

Get only needed data #100

Closed sdudnic closed 4 years ago

sdudnic commented 4 years ago
  1. What should I do to get the data only from France?

I open the (https://covid19-graphql.now.sh/) site and play the following query

{
  country(name:"France") {
    results {
      date
      confirmed
      recovered
      deaths
      growthRate
    }
  }
}

I need only France, so I copy the query as fetch

fetch("https://covid19-graphql.now.sh/", {
        "credentials": "omit",
        "headers": {
            "accept": "*/*",
            "accept-language": "fr,ru;q=0.9,en;q=0.8,en-US;q=0.7,ro;q=0.6,de;q=0.5",
            "cache-control": "no-cache",
            "content-type": "application/json",
            "pragma": "no-cache",
            "sec-fetch-dest": "empty",
            "sec-fetch-mode": "cors",
            "sec-fetch-site": "same-origin"
        },
        "referrer": "https://covid19-graphql.now.sh/",
        "referrerPolicy": "no-referrer-when-downgrade",
        "body": "{\"operationName\":null,\"variables\":{},\"query\":\"{\\n  country(name: \\\"France\\\") {\\n    results {\\n      date\\n      confirmed\\n      recovered\\n      deaths\\n      growthRate\\n    }\\n  }\\n}\\n\"}",
        "method": "POST",
        "mode": "cors"
    })

expecting to obtain

{
  "data": {
    "country": {
      "results": [
        {
          "date": "2020-1-22",
          "confirmed": 0,
          "recovered": 0,
          "deaths": 0,
          "growthRate": 0
        },
        {
          "date": "2020-1-23",
          "confirmed": 0,
          "recovered": 0,
          "deaths": 0,
          "growthRate": null
        },

        { ... },

        {
          "date": "2020-3-27",
          "confirmed": 33402,
          "recovered": 5707,
          "deaths": 1997,
          "growthRate": 0.13031707894825895
        },
        {
          "date": "2020-3-28",
          "confirmed": 38105,
          "recovered": 5724,
          "deaths": 2317,
          "growthRate": 0.14079995209867674
        }
      ]
    }
  }
}
  1. Is it possible, in order do not need to parse the data, the date to be in UTC milliseconds?
pomber commented 4 years ago

Hi! the graphql api has another repo and maintainer. Try opening the issue there.

sdudnic commented 4 years ago

this does not close the question of what I do if I need only one country :)

pomber commented 4 years ago

this does not close the question of what I do if I need only one country :)

You can't get just one country from the json file. Try some of the APIs listed on the readme, and ask in their respective repositories if you have issues.