PHPackages                             flashmatt/postcodesio - 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. flashmatt/postcodesio

ActiveLibrary[API Development](/categories/api)

flashmatt/postcodesio
=====================

A simple interface for querying the Postcodes.io UK postcode API.

1.3(8y ago)0458MITPHPPHP ~5.5|~7.0

Since Mar 4Pushed 8y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (3)Versions (5)Used By (0)

PostcodesIo
===========

[](#postcodesio)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Description
-----------

[](#description)

A simple interface for querying the Postcodes.io UK postcode API using [GuzzleHttp Version 6](http://docs.guzzlephp.org/en/latest/index.html).

Install
-------

[](#install)

Via Composer

```
$ composer require PhilKershaw/postcodesio
```

Usage
-----

[](#usage)

Simply import the `flashmatt\PostcodesIO\Client` class, create and instance and call any of the following methods:

```
use PhilKershaw\PostcodesIO\Client;

$client = new Client;

// Will return a whole host of information pertaining to the given post code.
$response = $client->postcodeLookup('W1A 1AA');

// Array containing postcodes.
$response = $client->bulkPostcodeLookup(['W1A 1AA', 'M50 2EQ']);

// Associative array containing latitude/longitude coordinates.
$response = $client->latLongLookup([
    'longitude' => 0.629834723775309,
    'latitude'  => 51.7923246977375
]);

// Nested associative arrays containing latitude/longitude coordinates and optional radius and limit.
// Radius will limit the range of the search and limit will, well, limit the number of results
// for a particular latitude/longitude lookup.
$response = $client->bulkLatLongLookup([
    [
        "longitude" => 0.629834723775309,
        "latitude"  => 51.7923246977375
    ],
    [
        "longitude" => -2.49690382054704,
        "latitude"  => 53.5351312861402,
        "radius"    => 1000,
        "limit"     => 5
    ]
]);

// Literally returns a random postcode.
$response = $client->getRandomPostcode();

$response = $client->validatePostcode('W1A 1AA');

// Will complete a partial postcode. Not tested thoroughly.
$response = $client->autocompletePostcode('W1A');

// Will return the nearest postcodes to a given post code.
$response = $client->getNearestPostcodes('W1A 1AA');

// Will perform an outcode lookup and return details specific to the outcode.
// NB The outcode refers to the first portion of the postcode.
// For example 'W1A' is the outcode in 'W1A 1AA'.
$response = $client->outcodeLookup('W1A');

// Similar to the nearest postcodes lookup but just for outcodes.
$response = $client->getNearestOutcodes('W1A');

// Similar to the straight lat/long lookup but just for outcodes.
$response = $client->outcodeLatLongLookup([
    'longitude' => 0.629834723775309,
    'latitude'  => 51.7923246977375
]);
```

All responses return an instance of `GuzzleHttp\Psr7\Response` which implements `Psr\Http\Message\ResponseInterface`. Therefore, you are able to fetch the status code simply by calling:

```
$response->getStatusCode();

```

and the headers:

```
$response->getHeaders();

```

a specific header:

```
$response->getHeader('Content-Type');

```

and the response body:

```
$response->getBody();

```

NB: The response from Postcodes.io typically takes the for of:

```
{
    "status": 200,
    "result": {...}
}
```

However, since the 'status' duplicates the HTTP response code `getBody()` will actually return just the 'result' allowing for example:

```
$postcode = json_decode($response->getBody())->postcode;
// OR
$latitude = json_decode($response->getBody())->latitude;
```

For further reading, checkout out the GuzzleHttp documentation as linked in the description.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~250 days

Total

4

Last Release

3018d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8735527?v=4)[Matt Davis](/maintainers/flashmatt)[@flashmatt](https://github.com/flashmatt)

---

Top Contributors

[![flashmatt](https://avatars.githubusercontent.com/u/8735527?v=4)](https://github.com/flashmatt "flashmatt (7 commits)")

---

Tags

postcodes.iophilkershaw

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.3M7](/packages/avalara-avataxclient)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1942.4k4](/packages/aimeos-prisma)

PHPackages © 2026

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