covidtracking
v0.1.1
Published
Covid-19 Tracking API Client
Downloads
3
Maintainers
Readme
Covid Tracking API Client
JavaScript HTTP client for making requests to Covid Tracking API. Use it in your server-side (Node.js) or browser applications to fetch Covid tracking data.
Installation
npm install covidtracking
Usage
Initialize the client
The module exports the covidtracking
Object. Just import the module and you are ready to make calls.
const covidtracking = require('covidtracking');
Call a method
The covidtracking
object has a named method for each of the endpoints in the Covid Tracking API. All named methods return a Promise which resolves with the response data or rejects with an error.
(async () => {
// Get recent daily numbers for [US](https://covidtracking.com/api/states).
const data = await covidtracking.us.daily();
// Display the data
console.log(data);
})();
Methods list
- States current -
states()
|states.csv()
- States daily -
states.daily()
|states.daily.csv()
- States info -
states.info()
|states.info.csv()
- US current -
us()
|us.csv()
- US daily -
us.daily()
|us.daily.csv()
- Counties-
counties()
|counties.csv()
- Tracker URLs -
urls()
- State Website Screenshots -
screenshots()
If you want to apply filter to us.daily()
, you can pass query strings as objects { state: 'NY' }
to only show cases in New York. Or { state: 'NY', date: '20200316'}
to show the result of a specific date.
const data = await covidtracking.us.daily({
state: 'NY',
date: '20200316'
});
Requirements
This package supports Node v8 LTS & higher and works on all modern browsers.