baikho / loqate-php
A PHP Wrapper for the Loqate API
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^6.5 || ^7.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18 || ^3.0
README
PHP Wrapper for the Loqate API.
Table of contents
- Requirements
- Installation
- Quick start
- Address verification
- Geocoding
- Email verification
- Bank account verification
- Phone verification
- License
Requirements
- PHP 8.1+
- Guzzle 6.5+ or 7.2+
Installation
composer require baikho/loqate-php
Quick start
Create a client with your Loqate API key, then use the product entry points as read-only properties ($client->address, $client->geocoding, $client->email, $client->phone, $client->bankAccount):
use Baikho\Loqate\Loqate; $client = new Loqate('your-api-key'); $result = $client->address->find('SW1A 1AA');
The same entry points are also available as methods ($client->address(), $client->geocoding(), and so on). Both styles return a new handler each time.
All examples below use property access and assume $client is already constructed as shown.
Address verification
Capture Find v1.20 and Capture Retrieve v1.30 wrap address capture and retrieval.
Find (search):
$result = $client->address->find('foo');
Find with full control (extra query parameters):
use Baikho\Loqate\Address\Find; $result = new Find('your-api-key') ->setText('foo') ->setIsMiddleWare(true) ->setContainer('bar') ->setCountries('NL') ->makeRequest();
Retrieve by Loqate id:
$result = $client->address->retrieve('GB|RM|B|12345678');
Retrieve with full control:
use Baikho\Loqate\Address\Retrieve; $result = new Retrieve('your-api-key') ->setId('GB|RM|B|12345678') ->makeRequest();
Geocoding
Supported endpoints:
| API | Version | Loqate docs |
|---|---|---|
| Distance | v1.00 |
Distances and directions - Distance |
| Directions | v2.00 |
Distances and directions - Directions |
| International Geocode | v1.10 |
Geocoding - International Geocode |
| UK Find | v2.00 |
Geocoding - UK Find |
| UK Geocode | v2.10 |
Geocoding - UK Geocode |
| UK Retrieve | v2.00 |
Geocoding - UK Retrieve |
| UK Reverse Geocode | v1.10 |
Geocoding - UK Reverse Geocode |
Distance between two points - easting/northing, latitude/longitude, or postcodes (UK):
$result = $client->geocoding->distance('381600,259400', '380600,25840'); $result = $client->geocoding->distance('51.4733514399,-0.00088499646', '51.492914695,-0.1215161806'); $result = $client->geocoding->distance('SE10 8XJ', 'SW1A 0AA');
Directions - same coordinate formats as distance:
$result = $client->geocoding->directions('381600,259400', '380600,25840'); $result = $client->geocoding->directions('51.4733514399,-0.00088499646', '51.492914695,-0.1215161806'); $result = $client->geocoding->directions('SE10 8XJ', 'SW1A 0AA');
International geocode - country as ISO-2 or ISO-3; location can be postal code, place name, or Loqate id:
$result = $client->geocoding->geocode('GB', 'London');
UK find / geocode / retrieve - full or partial postcode, place name, or street, town style text:
$result = $client->geocoding->ukFind('London'); $result = $client->geocoding->ukGeocode('London'); $result = $client->geocoding->ukRetrieve('GB|RM|B|12345678');
UK reverse geocode - centre point as postcode or coordinates (latitude/longitude or easting/northing):
$result = $client->geocoding->ukReverseGeocode('51.4733514399,-0.00088499646');
Email verification
$result = $client->email->validate('foo@example.com');
Bank account verification
$result = $client->bankAccount->validate('12345678', '20-45-67');
Phone verification
$result = $client->phone->validate('1234567890'); $result = $client->phone->validate('1234567890', 'NL');
License
This package is released under the MIT License.