Zip Codes Lookup finds all postal codes within a US city or resolves a five-digit ZIP code to its city and state. Paid plans add the IANA time zone, geographic coordinates and the distance from the ZIP to a second ZIP.
Install via Composer:
composer require apiverve/zipcodesGet your API key at APIVerve
<?php
require_once 'vendor/autoload.php';
use APIVerve\Zipcodes\Client;
// Initialize the client
$client = new Client('YOUR_API_KEY');
// Make a request
$response = $client->execute([
'zip' => '64082',
'distanceTo' => '64106'
]);
// Print the response
print_r($response);use APIVerve\Zipcodes\Client;
use APIVerve\Zipcodes\Exceptions\APIException;
use APIVerve\Zipcodes\Exceptions\ValidationException;
try {
$response = $client->execute(['zip' => '64082', 'distanceTo' => '64106']);
print_r($response['data']);
} catch (ValidationException $e) {
echo "Validation error: " . implode(', ', $e->getErrors());
} catch (APIException $e) {
echo "API error: " . $e->getMessage();
echo "Status code: " . $e->getStatusCode();
}// Enable debug logging
$client = new Client(
apiKey: 'YOUR_API_KEY',
debug: true
);{
"status": "ok",
"error": null,
"data": {
"zipcode": "64082",
"state_abbr": "MO",
"latitude": "38.850243",
"longitude": "-94.39570",
"city": "Lees Summit",
"state": "Missouri",
"timezone": "America/Chicago",
"distance": {
"zipcode": "64106",
"city": "Kansas City",
"state_abbr": "MO",
"miles": 19.94,
"kilometers": 32.09
}
}
}- PHP 7.4 or higher
- Guzzle HTTP client
For more information, visit the API Documentation.
- Website: https://apiverve.com/marketplace/zipcodes?utm_source=php&utm_medium=referral&utm_content=readme
- Email: hello@apiverve.com
This package is available under the MIT License.