ziptastic / ziptastic
PHP SDK for the Ziptastic Lookup API
Installs: 8 631
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 4
Forks: 2
Open Issues: 0
Requires
- php: >=7.1
- php-http/client-implementation: ^1.0
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- guzzlehttp/psr7: ^1.4
- php-http/curl-client: ^1.7
- php-http/message: ^1.0
- php-http/mock-client: ^1.0
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2025-03-11 15:38:05 UTC
README
This library is a simple interface for the Ziptastic API.
Using Ziptastic requires an API key.
Installing
Ziptastic PHP can be installed via composer:
composer require ziptastic/ziptastic
Ziptastic PHP relies on HTTPlug to make API requests. HTTPlug is an abstraction which allows you to choose from any one of a large number of HTTP clients, including the client you might already have installed.
For more information on getting started with HTTPlug, please refer to the HTTPlug for library users documentation.
To just get moving right now, install a couple common dependencies:
composer require php-http/curl-client guzzlehttp/psr7 php-http/message
Usage
<?php include "vendor/autoload.php"; use Ziptastic\Client; $z = Client::create(getenv('ZIPTASTIC_API_KEY'));
Ziptastic provides two API methods: Lookup by a postal code (forward lookup), and lookup by latitude and longitude (reverse lookup).
$result = $z->forward(48038); $result = $z->reverse(42.331427, -83.0457538, 1000);
Results are returned as a list of arrays:
<?php $lookup = current($result); echo $lookup['county']; // Macomb echo $lookup['city']; // Clinton Township echo $lookup['state']; // Michigan echo $lookup['state_short']; // MI echo $lookup['postal_code']; // 48038 echo $lookup['latitude']; // 42.5868882 echo $lookup['longitude']; // -82.9195514 // Timezones are represented by an instance of \DateTimeZone echo $lookup['timezone']->getName(); // America/Detroit
PHP 5
If you require PHP 5 compatibility, please use Ziptastic-PHP version 1.
License
Ziptastic PHP is licensed under the MIT license.