PHPackages                             suilven/uk-covid-govt-api-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. suilven/uk-covid-govt-api-client

ActiveLibrary[API Development](/categories/api)

suilven/uk-covid-govt-api-client
================================

API Client to UK Govt Covid API

00PHP

Since Sep 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/gordonbanderson/uk-govt-covid-api-client)[ Packagist](https://packagist.org/packages/suilven/uk-covid-govt-api-client)[ RSS](/packages/suilven-uk-covid-govt-api-client/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Client to UK Govt Covid API
===============================

[](#php-client-to-uk-govt-covid-api)

[![Build Status](https://camo.githubusercontent.com/6c80abfc2058685ade05ed221991303688e0c64aae97117b760088e62c483034/68747470733a2f2f7472617669732d63692e6f72672f676f72646f6e62616e646572736f6e2f756b2d676f76742d636f7669642d6170692d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gordonbanderson/uk-govt-covid-api-client)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7c7a45691f5ea9995fcfada0ec70c18405763379162f38fd62bc83f698bb3847/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676f72646f6e62616e646572736f6e2f756b2d676f76742d636f7669642d6170692d636c69656e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/gordonbanderson/uk-govt-covid-api-client/?branch=master)[![codecov.io](https://camo.githubusercontent.com/5b18954461fafd22352163f2328ebf43af99e8d3e0a9a0ef586d46f28381dd89/68747470733a2f2f636f6465636f762e696f2f6769746875622f676f72646f6e62616e646572736f6e2f756b2d676f76742d636f7669642d6170692d636c69656e742f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/gordonbanderson/uk-govt-covid-api-client?branch=master)

[![Latest Stable Version](https://camo.githubusercontent.com/c1ea661976cb4fbba805819a80f24db1af987ddd18d2f6c093545399bb88c2c0/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f756b2d636f7669642d676f76742d6170692d636c69656e742f76657273696f6e)](https://packagist.org/packages/suilven/uk-covid-govt-api-client)[![Latest Unstable Version](https://camo.githubusercontent.com/1bd153ca13930f00639c7dc951f7bd1ba9e13aee65a084f238bb08785e1cc56a/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f756b2d636f7669642d676f76742d6170692d636c69656e742f762f756e737461626c65)](//packagist.org/packages/suilven/uk-covid-govt-api-client)[![Total Downloads](https://camo.githubusercontent.com/5d4a3f8a1b8af06bee971a429f7184c7513d8db42ce8f8ebad1a73a9933dc584/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f756b2d636f7669642d676f76742d6170692d636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/suilven/uk-covid-govt-api-client)[![License](https://camo.githubusercontent.com/e8d40bc54f08acd947236e388650a51f97f49d7af9c5492523b914cb9e5ac6a9/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f756b2d636f7669642d676f76742d6170692d636c69656e742f6c6963656e7365)](https://packagist.org/packages/suilven/uk-covid-govt-api-client)[![Monthly Downloads](https://camo.githubusercontent.com/35b384fcbe51eb99e880e26c953bdd7e2459f136f3d6fcdeb6f7506d13832523/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f756b2d636f7669642d676f76742d6170692d636c69656e742f642f6d6f6e74686c79)](https://packagist.org/packages/suilven/uk-covid-govt-api-client)[![Daily Downloads](https://camo.githubusercontent.com/3620f74c35696ad7fa2b5f075b4ea7e4d382225d0f146b380004ff8aa6d7c08f/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f756b2d636f7669642d676f76742d6170692d636c69656e742f642f6461696c79)](https://packagist.org/packages/suilven/uk-covid-govt-api-client)[![composer.lock](https://camo.githubusercontent.com/f8b68926f782faf819674bb7e5d694d0a3a5c01fa6aefba0c2c76b57d4e729ab/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f756b2d636f7669642d676f76742d6170692d636c69656e742f636f6d706f7365726c6f636b)](https://packagist.org/packages/suilven/uk-covid-govt-api-client)

[![GitHub Code Size](https://camo.githubusercontent.com/ff4593457f68694621b0d35952d35b8509c300597dd107e7679681d35bb86e53/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f676f72646f6e62616e646572736f6e2f756b2d676f76742d636f7669642d6170692d636c69656e74)](https://github.com/gordonbanderson/uk-govt-covid-api-client)[![GitHub Repo Size](https://camo.githubusercontent.com/c7fed0256acb34b263a5fcb0ae4307e947a7c024a724da4a3eef927baab7314b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f676f72646f6e62616e646572736f6e2f756b2d676f76742d636f7669642d6170692d636c69656e74)](https://github.com/gordonbanderson/uk-govt-covid-api-client)[![GitHub Last Commit](https://camo.githubusercontent.com/cab9b3f88eec9b574cb3aeef5444fb5f8aeec06ecc00049c23b14e39c0eb0627/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f676f72646f6e62616e646572736f6e2f756b2d676f76742d636f7669642d6170692d636c69656e74)](https://github.com/gordonbanderson/uk-govt-covid-api-client)[![GitHub Activity](https://camo.githubusercontent.com/372caf665ce0f51a69dd158b751ca3fe8623fc49875c7c3ab7e109e820947e77/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6d6d69742d61637469766974792f6d2f676f72646f6e62616e646572736f6e2f756b2d676f76742d636f7669642d6170692d636c69656e74)](https://github.com/gordonbanderson/uk-govt-covid-api-client)[![GitHub Issues](https://camo.githubusercontent.com/bcb3dc3680273f4668dea921b4cffacfcf2702398610f1d1561cca47e0c03cc6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f676f72646f6e62616e646572736f6e2f756b2d676f76742d636f7669642d6170692d636c69656e74)](https://github.com/gordonbanderson/uk-govt-covid-api-client/issues)

[![codecov.io](https://camo.githubusercontent.com/a0893afdcd859e2dd70ace5e1561912e00f33eb21358ec3974c9edbd78e655d7/68747470733a2f2f636f6465636f762e696f2f6769746875622f676f72646f6e62616e646572736f6e2f756b2d676f76742d636f7669642d6170692d636c69656e742f6272616e63682e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/a0893afdcd859e2dd70ace5e1561912e00f33eb21358ec3974c9edbd78e655d7/68747470733a2f2f636f6465636f762e696f2f6769746875622f676f72646f6e62616e646572736f6e2f756b2d676f76742d636f7669642d6170692d636c69656e742f6272616e63682e7376673f6272616e63683d6d6173746572)

Background
==========

[](#background)

The UK Government has provided an API for accessing COVID data. The documentation is poor, see  , and if the structure parameter is missing the API call redirects to the documentation above (!).

I am not sure about how often and indeed how soon the data is updated, but hopefully it proves of use to the PHP community.

Installation
============

[](#installation)

Existing PHP Environment
------------------------

[](#existing-php-environment)

If you have an existing PHP environment, install as follows:

```
composer require suilven/uk-covid-govt-api-client

```

Docker
------

[](#docker)

A Docker environment is provided for, primarily to run unit tests

```
sudo docker-compose up -d phpcli
sudo docker-compose exec /bin/bash
composer install

```

Usage
=====

[](#usage)

Get An Area Type
----------------

[](#get-an-area-type)

An area type is mandatory, but defaults to a level of nation. This can be set as follows:

```
use Suilven\CovidAPIClient\Factory\AreaTypeFactory;
use Suilven\CovidAPIClient\Filter\AreaType;

$factory = new AreaTypeFactory();
$areaType = $factory->getAreaType(AreaType::NATION);

```

```
public const OVERVIEW = 'overview';
public const NATION = 'nation';
public const REGION = 'region';
public const NHS_REGION = 'nhsRegion';
public const UPPER_TIER = 'utla';
public const LOWER_TIER = 'ltla';

```

Valid values for AreaType are as follows:

- `AreaType::OVERVIEW`
- `AreaType::NATION`
- `AreaType::REGION`
- `AreaType::NHS_REGION`
- `AreaType::UPPER_TIER`
- `AreaType::LOWER_TIER`

Valid values for upper and lower tier area names can be found in the docs directory.

Add a Filter
------------

[](#add-a-filter)

```
$factory = new AreaTypeFactory();
$areaType = $factory->getAreaType(AreaType::UPPER_TIER);
$client = new APIClient();
$filter = new Filter();
$filter->setAreaType($areaType);
$filter->setAreaName('Blackburn with Darwen');
$result = $client->getData([$filter]);

```

One can set a date, an area code or area name as above.

Get Results
-----------

[](#get-results)

Each recodr (of an array) is a `Suilven\CovidAPIClient\ModelgetRecords();

```

### Get Data For An Individual Result

[](#get-data-for-an-individual-result)

```
$record->getNewCasesByPublishDate();
$record->getNewDeaths28DaysByDeathDate();
$record->getCumCasesByPublishDate();
$record->getCumDeaths28DaysByDeathDate();
$record->getCumCasesByPublishDate();
$this->assertEquals('S12000027', $record->getAreaCode();
$this->assertEquals('Shetland Islands', $record->getAreaName();
$this->assertEquals('2020-09-21', $record->getDate())

```

COMMENTS
========

[](#comments)

This is a functional but rough implementation, although well tested.

I still do not fully understand how the data behind the API is updated, this is a bit of a black box.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/770fae946ca5ca8f0f1f0179462c84d3ca60e9bd32cac3f522fdb64c2e384789?d=identicon)[suilven](/maintainers/suilven)

---

Top Contributors

[![gordonbanderson](https://avatars.githubusercontent.com/u/7060?v=4)](https://github.com/gordonbanderson "gordonbanderson (29 commits)")

### Embed Badge

![Health badge](/badges/suilven-uk-covid-govt-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/suilven-uk-covid-govt-api-client/health.svg)](https://phpackages.com/packages/suilven-uk-covid-govt-api-client)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
