在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:ExpDev07/coronavirus-tracker-api开源软件地址:https://github.com/ExpDev07/coronavirus-tracker-api开源编程语言:Python 99.0%开源软件介绍:Coronavirus Tracker APIProvides up-to-date data about Coronavirus outbreak. Includes numbers about confirmed cases, deaths and recovered. Support multiple data-sources. Live global stats (provided by fight-covid19/bagdes) from this API: New York Times is now available as a source!Specify source parameter with ?source=nyt. NYT also provides a timeseries! To view timelines of cases by US counties use ?source=nyt&timelines=true Recovered cases showing 0JHU (our main data provider) no longer provides data for amount of recoveries, and as a result, the API will be showing 0 for this statistic. Apologies for any inconvenience. Hopefully we'll be able to find an alternative data-source that offers this. Available data-sources:Currently 3 different data-sources are available to retrieve the data:
jhu data-source will be used as a default source if you don't specify a source parameter in your request. API ReferenceAll endpoints are located at You can open the URL in your browser to further inspect the response. Or you can make this curl call in your terminal to see the prettified response:
Swagger/OpenAPIConsume our API through our super awesome and interactive SwaggerUI (on mobile, use the mobile friendly ReDocs instead for the best experience). The OpenAPI json definition can be downloaded at https://coronavirus-tracker-api.herokuapp.com/openapi.json API EndpointsSources EndpointGetting the data-sources that are currently available to Coronavirus Tracker API to retrieve the data of the pandemic. GET /v2/sources Sample response {
"sources": [
"jhu",
"csbs",
"nyt"
]
} Latest EndpointGetting latest amount of total confirmed cases, deaths, and recovered. GET /v2/latest Query String Parameters
Sample response {
"latest": {
"confirmed": 197146,
"deaths": 7905,
"recovered": 80840
}
} Locations EndpointGetting latest amount of confirmed cases, deaths, and recovered per location. The Location ObjectGET /v2/locations/:id Path Parameters
Query String Parameters
Example RequestGET /v2/locations/39 Sample response {
"location": {
"id": 39,
"country": "Norway",
"country_code": "NO",
"country_population": 5009150,
"province": "",
"county": "",
"last_updated": "2020-03-21T06:59:11.315422Z",
"coordinates": { },
"latest": { },
"timelines": {
"confirmed": {
"latest": 1463,
"timeline": {
"2020-03-16T00:00:00Z": 1333,
"2020-03-17T00:00:00Z": 1463
}
},
"deaths": { },
"recovered": { }
}
}
} List of all locationsGET /v2/locations Query String Parameters
Sample response {
"latest": {
"confirmed": 272166,
"deaths": 11299,
"recovered": 87256
},
"locations": [
{
"id": 0,
"country": "Thailand",
"country_code": "TH",
"country_population": 67089500,
"province": "",
"county": "",
"last_updated": "2020-03-21T06:59:11.315422Z",
"coordinates": {
"latitude": "15",
"longitude": "101"
},
"latest": {
"confirmed": 177,
"deaths": 1,
"recovered": 41
}
},
{
"id": 39,
"country": "Norway",
"country_code": "NO",
"province": "",
"county": "",
"last_updated": "2020-03-21T06:59:11.315422Z",
"coordinates": {
"latitude": "60.472",
"longitude": "8.4689"
},
"latest": {
"confirmed": 1463,
"deaths": 3,
"recovered": 1
}
}
]
} Response definitions
Example Requests with parametersParameter: country_code Getting data for the Country specified by the country_code parameter, in this case Italy - IT GET /v2/locations?country_code=IT Sample Response {
"latest": {
"confirmed": 59138,
"deaths": 5476,
"recovered": 7024
},
"locations": [
{
"id": 16,
"country": "Italy",
"country_code": "IT",
"country_population": 60340328,
"province": "",
"county": "",
"last_updated": "2020-03-23T13:32:23.913872Z",
"coordinates": {
"latitude": "43",
"longitude": "12"
},
"latest": {
"confirmed": 59138,
"deaths": 5476,
"recovered": 7024
}
}
]
} Parameter: source Getting the data from the data-source specified by the source parameter, in this case csbs GET /v2/locations?source=csbs Sample Response {
"latest": {
"confirmed": 7596,
"deaths": 43,
"recovered": 0
},
"locations": [
{
"id": 0,
"country": "US",
"country_code": "US",
"country_population": 310232863,
"province": "New York",
"state": "New York",
"county": "New York",
"last_updated": "2020-03-21T14:00:00Z",
"coordinates": {
"latitude": 40.71455,
"longitude": -74.00714
},
"latest": {
"confirmed": 6211,
"deaths": 43,
"recovered": 0
}
},
{
"id": 1,
"country": "US",
"country_code": "US",
"country_population": 310232863,
"province": "New York",
"state": "New York",
"county": "Westchester",
"last_updated": "2020-03-21T14:00:00Z",
"coordinates": {
"latitude": 41.16319759,
"longitude": -73.7560629
},
"latest": {
"confirmed": 1385,
"deaths": 0,
"recovered": 0
},
}
]
} Parameter: timelines Getting the data for all the locations including the daily tracking of confirmed cases, deaths and recovered per location. GET /v2/locations?timelines=1 Explore the response by opening the URL in your browser https://coronavirus-tracker-api.herokuapp.com/v2/locations?timelines=1 or make the following curl call in your terminal:
NOTE: Timelines tracking starts from day 22nd January 2020 and ends to the last available day in the data-source. WrappersThese are the available API wrappers created by the community. They are not necessarily maintained by any of this project's authors or contributors. PHPGolangC#PythonJavaNode.jsRubyLuaPrerequisitesYou will need the following things properly installed on your computer. Installation
And don't despair if don't get the python setup working on the first try. No one did. Guido got pretty close... once. But that's another story. Good luck. Running / DevelopmentFor a live reloading on code changes.
Without live reloading.
Visit your app at http://localhost:8000. Alternatively run our API with Docker. Running Testspipenv run test Lintingpipenv run lint Formattingpipenv run fmt Update requirements filesinvoke generate-reqs Pipfile.lock will be automatically updated during DockerOur Docker image is based on tiangolo/uvicorn-gunicorn-fastapi/. invoke docker --build Run with Alternate Docker imagesIf a full InvokeAdditional developer commands can be run by calling them with the python invoke --list Deploying
Contributors |
请发表评论