A Modern PHP Wrapper for the Loqate API.
- Requirements
- Installation
- Quick start
- Address verification
- Geocoding
- Email verification
- Bank account verification
- Phone verification
- License
- PHP 8.1+
- Guzzle 6.5+ or 7.2+
composer require baikho/loqate-phpCreate 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.
Supported endpoints:
| API | Version | Loqate docs |
|---|---|---|
| Capture Find | v1.20 |
Address capture - Find |
| Capture Retrieve | v1.30 |
Address capture - Retrieve |
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();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');Supported endpoints:
| API | Version | Loqate docs |
|---|---|---|
| Individual validate | v2.00 |
Email validation - Individual |
$result = $client->email->validate('foo@example.com');Supported endpoints:
| API | Version | Loqate docs |
|---|---|---|
| Individual validate | v2.00 |
Bank validation - Individual |
$result = $client->bankAccount->validate('12345678', '20-45-67');Supported endpoints:
| API | Version | Loqate docs |
|---|---|---|
| Individual validate | v2.20 |
Phone validation - Individual validate |
$result = $client->phone->validate('1234567890');
$result = $client->phone->validate('1234567890', 'NL');This package is released under the MIT License.