Home

Awesome

CovidPHP

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.

Installation

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';

Usage

Create a instance of the API wrapper first:

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

Available methods

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

Further information

Examples

Get all available sources:

$covidApi->getSources();

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

$covidApi->getLatest();

Get all locations:

$covidApi->getAllLocations();

Get all locations including timelines:

$covidApi->getAllLocations(true);

Get location data by country code:

$covidApi->findByCountryCode('DE');

Get location data by country code from csbs as source:

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

Get location data for a specific location:

$covidApi->findByLocation(11);

Note

License

MIT License