This module integrates Postcodes IO API with Drupal. This module provides a number of services that provide access to various API endpoints and data.
About Postcodes.io
Postcodes.io is a free Postcode & Geolocation API for the UK. Free, Open Source and based solely on Open Data, Postcodes.io is aimed at developers who want a resource to lookup and (reverse) geocode UK Postcodes.

Features
- Postcode lookup, resolve administrative and location data for postcodes and outward codes
- Postcode search & autocomplete
- Reverse geocode postcodes
- Nearest postcode search
- Terminated postcode search
- Outward code lookup
- Bulk postcode lookup and reverse geocoding
Install Module
composer require drupal/postcodes_io_api
drush en postcodes_io_apiServices:
Postcodes IO API Client Service
Postcodes IO API Client, this is the core connector between Drupal and Postcodes IO. It uses Guzzle to request API calls.
Methods:
Lookup a postcode
This uniquely identifies a postcode.
Request:
$this->postcodesIoApiClient->lookup(['postcode' => 'SW1A 0AA']);
Response:
{
"status": 200,
"result": {
"postcode": "SW1A 0AA",
"quality": 1,
"eastings": 530268,
"northings": 179545,
"country": "England",
"nhs_ha": "London",
"longitude": -0.124663,
"latitude": 51.49984,
"european_electoral_region": "London",
"primary_care_trust": "Westminster",
"region": "London",
"lsoa": "Westminster 020C",
"msoa": "Westminster 020",
"incode": "0AA",
"outcode": "SW1A",
"parliamentary_constituency": "Cities of London and Westminster",
"admin_district": "Westminster",
"parish": "Westminster, unparished area",
"admin_county": null,
"admin_ward": "St James's",
"ced": null,
"ccg": "NHS Central London (Westminster)",
"nuts": "Westminster",
"codes": {
"admin_district": "E09000033",
"admin_county": "E99999999",
"admin_ward": "E05000644",
"parish": "E43000236",
"parliamentary_constituency": "E14000639",
"ccg": "E38000031",
"ced": "E99999999",
"nuts": "UKI32"
}
}
}
Bulk Postcode Lookup.
Returns a list of matching postcodes and respective available data.
Reverse Geocoding.
Returns nearest postcodes for a given longitude and latitude.
Bulk Reverse Geocoding
Bulk translates geolocations into Postcodes. Accepts up to 100 geolocations.
Postcode Query
Submit a postcode query and receive a complete list of postcode matches and all associated postcode data.
Postcode Validation
Method to validate a postcode.
Postcode Autocomplete
Convenience method to return an list of matching postcodes.
Random Postcode
Returns a random postcode and all available data for that postcode.
Outward Code Lookup
Geolocation data for the centroid of the outward code specified.
Resources
Project information
Seeking new maintainer
The current maintainers are looking for new people to take ownership.- Project categories: Integrations
1 site reports using this module
- Created by dakku on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
