Package Exports
- covidtracking
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (covidtracking) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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 covidtrackingUsage
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.