CovidPHP is a PHP API wrapper for the coronavirus tracking API

1.2.1 2022-06-22 07:41 UTC

This package is not auto-updated.

Last update: 2024-05-09 01:24:36 UTC


CovidPHP is a PHP API wrapper for the Coronavirus tracker API.

Per default the data is provided by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE), but you can also use csbs as source.


You can install o-ba/covid-php using Composer:

composer require o-ba/covid-php

Require the composer autoloader in your script:

require 'vendor/autoload.php';


Create a instance of the API wrapper first:

$covidApi = new \Bo\CovidPHP\CovidApi();

Available methods

Methods Parameters Description
getSources() Get all available sources.
getLatest() string $source Get the latest data summarized.
getAllLocations() bool $includeTimelines (optional)
string $source (optional)
Get all available locations.
findByCountryCode() string $countryCode
bool $includeTimelines (optional)
string $source (optional)
Get country specific data based on the country code.
findByLocation() int $locationId
bool $includeTimelines (optional)
string $source (optional)
Get location specific data based on the location id.

Further information

  • Setting $includeTimelines adds timeline data to the response
  • Setting $source let's you specify which source the data should be fetched from (default: jhu)


Get all available sources:


Get the latest global amount of total confirmed cases, deaths and recoveries:


Get all locations:


Get all locations including timelines:


Get location data by country code:


Get location data by country code from csbs as source:

$covidApi->findByCountryCode('US', false, 'csbs');

Get location data for a specific location:



  • All responses will be decoded and returned as array


MIT License