PHPackages                             firstclasspostcodes/firstclasspostcodes - 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. firstclasspostcodes/firstclasspostcodes

ActiveLibrary[API Development](/categories/api)

firstclasspostcodes/firstclasspostcodes
=======================================

PHP bindings for the Firstclasspostcodes API

0234[1 issues](https://github.com/firstclasspostcodes/firstclasspostcodes-php/issues)PHP

Since Nov 27Pushed 5y ago1 watchersCompare

[ Source](https://github.com/firstclasspostcodes/firstclasspostcodes-php)[ Packagist](https://packagist.org/packages/firstclasspostcodes/firstclasspostcodes)[ RSS](/packages/firstclasspostcodes-firstclasspostcodes/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

[![Cover](/.github/images/cover.png)](/.github/images/cover.png)

Firstclasspostcodes
===================

[](#firstclasspostcodes)

The Firstclasspostcodes PHP library provides convenient access to the Firstclasspostcodes API from applications written in the PHP language. It includes pre-defined methods and helpers to help you easily integrate the library into any application.

The library also provides other features. For example:

- Easy configuration path for fast setup and use.
- Helpers for listing and formatting addresses.
- Built-in methods for easily interacting with the Firstclasspostcodes API.

Documentation
-------------

[](#documentation)

See [PHP API docs](https://docs.firstclasspostcodes.com/php/getting-started) for detailed usage and examples.

Installation
------------

[](#installation)

You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:

```
composer require firstclasspostcodes/firstclasspostcodes
```

To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):

```
require_once('vendor/autoload.php');
```

### Manual Installation

[](#manual-installation)

If you do not wish to use Composer, you can download the [latest release](https://github.com/firstclasspostcodes/firstclasspostcodes-php/releases). Then, to use the bindings, include the `init.php` file.

```
require_once('/path/to/firstclasspostcodes-php/init.php');
```

Requirements
------------

[](#requirements)

PHP 5.6.0 and later.

Usage
-----

[](#usage)

The library needs to be configured with your API key, which is available on the [dashboard](https://dashboard.firstclasspostcodes.com).

```
$API_KEY = getenv('API_KEY');

$client = new \Firstclasspostcodes\Client(['apiKey' => $API_KEY ]);

$data = $client->getPostcode('AB30 1FR');

echo json_encode($data, JSON_PRETTY_PRINT);
```

Configuration
-------------

[](#configuration)

The library can be configured with several options depending on the requirements of your setup:

```
$client = new \Firstclasspostcodes\Client([
  # The API Key to be used when sending requests to the
  # Firstclasspostcodes API
  'apiKey' => '3454tyrgdfsew23',

  # The host to send API requests to. This is typically changed
  # to use the mock service for testing purposes
  'host' => "api.firstclasspostcodes.com",

  # The default content type is json, but can be changed to "geo+json"
  # to return responses as GeoJSON content type
  'content' => "json",

  # Typically, always HTTPS, but useful to change for testing
  # purposes
  'protocol' => "https",

  # The base path is "/data", but useful to change for testing
  # purposes
  'basePath' => "/data",

  # The default request timeout for the library.
  'timeout'=> 30,
)
```

Events
------

[](#events)

You can subscribe to events using an initialized client, passing a function as a handler:

```
$client = new \Firstclasspostcodes\Client(['apiKey' => 'dea24tgf' ]);

$client->on('request', function ($request) {
  echo json_encode($request, JSON_PRETTY_PRINT);
});
```

Event nameDescription`request`Triggered before a request is sent. The request object to be sent is passed to the event handler.`response`Triggered with the parsed JSON response body upon a successful request.`error`Triggered with a client error when the request fails.`operation:{name}`Triggered by an operation with the parameter object.**Note:** `{name}` is replaced with the operation name of the method, as defined inside the OpenAPI specification.

Integration / Testing
---------------------

[](#integration--testing)

We provide a mock service of our API as a docker container [available here](https://github.com/firstclasspostcodes/firstclasspostcodes-mock). Once the container is running, the library can be easily configured to use it:

```
$client = new \Firstclasspostcodes\Client([
  'apiKey' => getenv('MOCK_API_KEY'),
  'protocol' => 'http',
  'host' => getenv('MOCK_API_HOST'),
  'basePath' => '/',
]);

$client->getPostcode('AB30 1FR');
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 91.2% 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/581b52f7c2de245055d89a3789befa7a803e87de7c270081a3dddd17064ae7b5?d=identicon)[davidkelley](/maintainers/davidkelley)

---

Top Contributors

[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (134 commits)")[![davidkelley](https://avatars.githubusercontent.com/u/1774262?v=4)](https://github.com/davidkelley "davidkelley (13 commits)")

### Embed Badge

![Health badge](/badges/firstclasspostcodes-firstclasspostcodes/health.svg)

```
[![Health](https://phpackages.com/badges/firstclasspostcodes-firstclasspostcodes/health.svg)](https://phpackages.com/packages/firstclasspostcodes-firstclasspostcodes)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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