Authentication overview

The Covid Tracking Project API provides free, public access to historical data on COVID-19 testing, cases, hospitalizations, and deaths across U.S. states and territories. Unlike many APIs that require authentication mechanisms such as API keys or OAuth tokens, the Covid Tracking Project API operates without any such requirements. This design choice was made to maximize accessibility for researchers, journalists, and the public during the pandemic, allowing anyone to fetch data directly without needing to register or manage credentials. The project ceased active data collection on March 7, 2021, but its comprehensive historical dataset remains available through its API for ongoing analysis and research purposes.

The absence of authentication simplifies integration significantly, as developers do not need to implement credential storage, rotation, or secure transmission protocols for API keys. This approach reduces the operational overhead for consumers of the data, making it straightforward to build applications, dashboards, and research tools that leverage the Covid Tracking Project's dataset. While this model prioritizes ease of access, it also means that all requests are treated equally, without rate limiting based on individual user identity, which is typically managed through authentication. The Covid Tracking Project's official API documentation confirms that no authentication is required for any endpoints, facilitating open data access.

Supported authentication methods

The Covid Tracking Project API does not support or require any authentication methods. All API endpoints are publicly accessible without the need for API keys, tokens, or any other form of credential. This design ensures open and unrestricted access to the historical COVID-19 data collected by the project. The API's architecture is built on the principle of open data, mirroring the project's mission to provide transparent and accessible information during the pandemic.

The following table outlines the authentication methods, their typical use cases, and security levels, contrasting them with the Covid Tracking Project's no-authentication approach:

Method When to Use Security Level Supported by Covid Tracking Project
No Authentication Public, open-access data where user identification is not required. Low (no user-specific security) Yes
API Key Rate limiting, basic access control, usage tracking. Medium (requires secure key management) No
OAuth 2.0 Delegated authorization, user consent, access to protected resources. High (token-based, scope-limited access) No
Basic Auth Simple client-server authentication, often over HTTPS. Medium (credentials sent with each request) No

For systems that do require authentication, such as the Stripe API authentication, understanding the different methods is crucial for secure integration. However, for the Covid Tracking Project API, this complexity is entirely absent, streamlining data retrieval for all users.

Getting your credentials

Since the Covid Tracking Project API does not require authentication, there are no credentials to obtain. You do not need to register for an account, generate an API key, or go through any setup process to access the data. The API is designed for immediate and unrestricted use.

To begin using the API, you can simply construct your request URL based on the Covid Tracking Project API documentation and send an HTTP GET request to the desired endpoint. For example, to retrieve current data for all states, you would access the /v1/states/current.json endpoint. No special headers or query parameters for authentication are needed.

This approach significantly lowers the barrier to entry, enabling quick integration into various applications and research workflows. Developers can focus directly on data consumption and analysis rather than managing authentication flows or securely storing sensitive credentials. The Covid Tracking Project API reference provides detailed information on available endpoints and data structures.

Authenticated request example

As the Covid Tracking Project API does not require authentication, an "authenticated" request is simply a standard HTTP GET request to the desired endpoint. There are no authentication headers, query parameters, or body content related to credentials to include.

Example: Fetching Current State Data (JSON)

To fetch the most current COVID-19 data for all U.S. states in JSON format, you would use the following endpoint:

GET https://api.covidtracking.com/v1/states/current.json
User-Agent: YourAppName/1.0 ([email protected])

The User-Agent header is optional but recommended as a best practice for identifying your application to the server, especially when consuming public APIs. This helps API providers understand usage patterns and contact you if necessary. For example, Mozilla's User-Agent header documentation explains its role in identifying client software.

Example: Fetching Daily Data for a Specific State (JSON)

To retrieve historical daily data for a specific state, such as New York (NY), you would use an endpoint like this:

GET https://api.covidtracking.com/v1/us/daily.json
User-Agent: MyResearchApp/2.0

This request directly accesses the data without any authentication challenges. The API will respond with the requested data in JSON format, provided the endpoint and parameters are valid according to the Covid Tracking Project API reference.

Because there is no authentication, the process of making a request is identical to accessing any public web resource. This simplicity is a core feature of the Covid Tracking Project's API design, facilitating widespread use and integration.

Security best practices

While the Covid Tracking Project API does not require authentication, certain security best practices are still relevant for consumers of the data, primarily concerning data integrity, application security, and responsible usage.

  1. Use HTTPS for all requests: Always access the API using https:// to ensure that your communication with the server is encrypted. This protects against eavesdropping and tampering of the data in transit, even if the data itself is public. While the Covid Tracking Project API defaults to HTTPS, explicitly specifying it in your requests is a good habit.
  2. Validate Data: Even from a trusted source, it is good practice to validate the format and content of the data received from any external API. This helps protect your application from unexpected data structures or potentially malformed responses that could lead to vulnerabilities or errors.
  3. Implement Robust Error Handling: Your application should be designed to gracefully handle various HTTP status codes (e.g., 404 Not Found, 500 Internal Server Error) and network issues. This prevents your application from crashing or behaving unpredictably if the API is temporarily unavailable or returns an error.
  4. Avoid Hardcoding URLs: If possible, configure API endpoints in your application rather than hardcoding them directly into your source code. This allows for easier updates if the base URL changes or if you need to switch between different environments (e.g., production and testing, though the Covid Tracking Project has a single public API).
  5. Respect Rate Limits (Implicitly): Although the Covid Tracking Project API does not enforce explicit per-user rate limits due to the lack of authentication, it is still crucial to make requests responsibly. Avoid making an excessive number of requests in a short period, which could strain the server and negatively impact other users. Implement caching mechanisms where appropriate to reduce redundant API calls.
  6. Secure Your Application: Focus on securing your own application that consumes the Covid Tracking Project data. If your application processes or stores any user data, ensure it follows general security principles like input validation, secure storage, and protection against common web vulnerabilities (e.g., XSS, CSRF).
  7. Monitor API Status: Keep an eye on the Covid Tracking Project's official communication channels or status pages (if available) for any announcements regarding API availability or changes. While the project ceased active data collection, the API remains available for historical data access.

By adhering to these best practices, developers can ensure that their applications securely and reliably consume the valuable historical data provided by the Covid Tracking Project API.