# Postcodes.io API

> Returns UK postcode lookups, nearest postcodes, autocomplete, validation and outcode details with position and administrative areas.

Category: Government & Open Data. Region: GB. 10 endpoints at `https://api.hoshime.com/v1/postcodesuk/<endpoint>`, `GET` with query parameters, answering `{data, meta}` (see https://hoshime.com/docs/responses.md). Reference: https://hoshime.com/docs/platforms/postcodesuk
## GET /v1/postcodesuk/lookup

One UK postcode with its country, region, district, constituency and position.

Scope: `social:read` · Units: 1 · Cached: 1440 min

| Parameter | Type | Required | Description |
|---|---|---|---|
| `postcode` | string | yes | UK postcode, such as SW1A 1AA. (e.g. SW1A 1AA) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `adminDistrict` (string), `constituency` (string), `country` (string), `distance` (number (double)), `latitude` (number (double)), `longitude` (number (double)), `postcode` (string), `region` (string)

```bash
curl "https://api.hoshime.com/v1/postcodesuk/lookup?postcode=SW1A+1AA" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/postcodesuk/reverse

The UK postcodes nearest to a point, closest first.

Scope: `social:read` · Units: 1 · Cached: 1440 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `latitude` | string | yes | Latitude of the point, such as 51.5072. (e.g. 51.5072) |
| `longitude` | string | yes | Longitude of the point, such as -0.1276. (e.g. -0.1276) |
| `limit` | integer | no | Postcodes to return, from 1 to 100. (default 10) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `adminDistrict` (string), `constituency` (string), `country` (string), `distance` (number (double)), `latitude` (number (double)), `longitude` (number (double)), `postcode` (string), `region` (string)

```bash
curl "https://api.hoshime.com/v1/postcodesuk/reverse?latitude=51.5072&longitude=-0.1276" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/postcodesuk/autocomplete

UK postcodes that start with the text, such as SW1A 1.

Scope: `social:read` · Units: 1 · Cached: 1440 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `query` | string | yes | Start of a postcode, such as SW1A1. (e.g. SW1A1) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `postcode` (string)

```bash
curl "https://api.hoshime.com/v1/postcodesuk/autocomplete?query=SW1A1" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/postcodesuk/nearestPostcodes

The UK postcodes nearest to one postcode, closest first, with their distance in metres.

Scope: `social:read` · Units: 1 · Cached: 1440 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `postcode` | string | yes | UK postcode, such as SW1A 1AA. (e.g. SW1A 1AA) |
| `limit` | integer | no | Postcodes to return, from 1 to 100. (default 10) |
| `radius` | integer | no | Search radius in metres, from 1 to 2000. (default 1000) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `adminDistrict` (string), `constituency` (string), `country` (string), `distance` (number (double)), `latitude` (number (double)), `longitude` (number (double)), `postcode` (string), `region` (string)

```bash
curl "https://api.hoshime.com/v1/postcodesuk/nearestPostcodes?postcode=SW1A+1AA" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/postcodesuk/validPostcode

Whether a postcode is a live UK postcode that Royal Mail delivers to.

Scope: `social:read` · Units: 1 · Cached: 1440 min

| Parameter | Type | Required | Description |
|---|---|---|---|
| `postcode` | string | yes | UK postcode, such as SW1A 1AA. (e.g. SW1A 1AA) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `postcode` (string), `valid` (boolean)

```bash
curl "https://api.hoshime.com/v1/postcodesuk/validPostcode?postcode=SW1A+1AA" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/postcodesuk/outcode

One outcode, the first half of a postcode such as SW1A, with its position and the districts, wards and constituencies it covers.

Scope: `social:read` · Units: 1 · Cached: 1440 min

| Parameter | Type | Required | Description |
|---|---|---|---|
| `outcode` | string | yes | Outcode, such as SW1A. (e.g. SW1A) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `adminDistricts` (string[]), `adminWards` (string[]), `country` (string), `latitude` (number (double)), `longitude` (number (double)), `outcode` (string), `parishes` (string[]), `parliamentaryConstituencies` (string[])

```bash
curl "https://api.hoshime.com/v1/postcodesuk/outcode?outcode=SW1A" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/postcodesuk/randomPostcode

A random live UK postcode with its position and area. Each call gives a different postcode.

Scope: `social:read` · Units: 1

| Parameter | Type | Required | Description |
|---|---|---|---|
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `adminDistrict` (string), `constituency` (string), `country` (string), `distance` (number (double)), `latitude` (number (double)), `longitude` (number (double)), `postcode` (string), `region` (string)

```bash
curl "https://api.hoshime.com/v1/postcodesuk/randomPostcode" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/postcodesuk/lookupMany

Several UK postcodes at once, with their area and position. A postcode that is not found has an empty entry.

Scope: `social:read` · Units: 1 · Cached: 1440 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `postcodes` | string | yes | Comma-separated UK postcodes, such as SW1A 1AA,M32 0JG (up to 100). (e.g. SW1A 1AA,M32 0JG) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `found` (boolean), `postcode` (Postcode), `postcode.adminDistrict` (string), `postcode.constituency` (string), `postcode.country` (string), `postcode.distance` (number (double)), `postcode.latitude` (number (double)), `postcode.longitude` (number (double)), `postcode.postcode` (string), `postcode.region` (string), `query` (string)

```bash
curl "https://api.hoshime.com/v1/postcodesuk/lookupMany?postcodes=SW1A+1AA%2CM32+0JG" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/postcodesuk/places

UK towns, villages and localities found by name, with their county, region and position.

Scope: `social:read` · Units: 1 · Cached: 1440 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `query` | string | yes | Name of the place, such as Oxford or Bath. (e.g. Oxford) |
| `limit` | integer | no | Places to return, from 1 to 100. (default 10) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `country` (string), `countyUnitary` (string), `districtBorough` (string), `latitude` (number (double)), `localType` (string), `longitude` (number (double)), `name` (string), `outcode` (string), `region` (string)

```bash
curl "https://api.hoshime.com/v1/postcodesuk/places?query=Oxford" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/postcodesuk/terminatedPostcode

A UK postcode that Royal Mail no longer delivers to, with the month and year it was terminated and its last position.

Scope: `social:read` · Units: 1 · Cached: 1440 min

| Parameter | Type | Required | Description |
|---|---|---|---|
| `postcode` | string | yes | Terminated UK postcode, such as B1 1AA. (e.g. B1 1AA) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `latitude` (number (double)), `longitude` (number (double)), `monthTerminated` (integer (int64)), `postcode` (string), `yearTerminated` (integer (int64))

```bash
curl "https://api.hoshime.com/v1/postcodesuk/terminatedPostcode?postcode=B1+1AA" -H "Authorization: Bearer $HOSHIME_TOKEN"
```
