This is an SDK written in PHP 7.1 in order to facilitate the interaction with the Snoopi.io API.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
For paid users of this service, you will need to specify an api key in order to gain higher performance and additional api features. Please ensure you have an account and the api key ready when calling this SDK. Otherwise you will be limited to 1 API call per second.
You can install the SDK in one of two ways.
One method is to download the directory and copy the contents to your project
or clone the repository and move it into the root of your project.
git clone https://github.com/jkassel/snoopiPHPSDK.git
This will give you a list of zip codes in a specified radius of an origin zip code
Usage: get_zip_code_radius(origin_zip_code, [radius])
parameter | data_type | required | default |
---|---|---|---|
origin_zip_code | string | YES | None |
radius | string | NO | "5" |
Response: array of zip codes ["string", "string",...]
This will give you location information based on a supplied IP address
Usage: get_location_by_ip(ip_address)
parameter | data_type | required | default |
---|---|---|---|
ip_address | string | YES | None |
Response:
{
"CountryCode": "string",
"CountryName": "string",
"GeoID": "number",
"State": "string",
"StateCode": "string",
"City": "string",
"Postal": "string",
"Latitude": "float",
"Longitude": "float",
"RequestTime": "int",
"RequestedIP": "string"
}
Gives you the distance between two zip codes
Usage: get_zip_code_distance(start_zip_code, end_zip_code):
parameter | data_type | required | default |
---|---|---|---|
start_zip_code | string | YES | None |
end_zip_code | string | YES | None |
Response:
{
"miles": "float",
"kilometers": "float"
}
Displays a list of US states
Usage: get_states():
None
Response: an array of dictionaries
[
{
"id": "int",
"code": "string",
"name": "string"
},
{"...": "..."}
]
Gives you the distance between two zip codes
Usage: get_state_abbreviation(state):
parameter | data_type | required | default |
---|---|---|---|
state | string | YES | None |
Response:
{
"code": "string",
"name": "string"
}
Gives you the distance between two zip codes
Usage: get_cities([state_abbreviation]):
parameter | data_type | required | default |
---|---|---|---|
state_abbreviation | string | NO | None |
Response:
[
{
"id": "int",
"zip_code": "string",
"state_prefix": "string",
"city": "string",
"county": "string",
"lon": "string",
"lat": "string"
},
{"...": "..."}
]
<?php
//import module
require __DIR__.'/SnoopiClient.php';
//instantiate the SDK
$my_api = new SnoopiClient();
//get list of zip codes within 5 miles of origin zip code
$result = $my_api->get_zip_code_radius("11214", "5");
print($result);
- Jeff Kassel - Initial work - jkassel
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details