This is an old revision of the document!
Table of Contents
GeoIP API
The API is *very* much in alpha, so let me know if you have any problems or requests.
JSON
Data will return in JSON by default.
If you pass a “callback” param, the data will be passed to a function using the callback value for the function name.
Using cURL
You can easily use cURL in the command line to test out responses.
Example:
curl http://geoip.prototypeapp.com/api/locate
API Methods
Many of these methods will return a HTTP 204 No Content on failure.
Locate Method
Methods to for locating by IP
locate
geoip.prototypeapp.com/api/locate
This method returns JSON (by default) or XML using the format parameter.
If you don't pass it an IP address, it will try to use the referrer's address.
| Parameter | Type |
|---|---|
| ip | string - an IP address |
| format | either 'xml' or 'json' - defaults to 'json' |
The response should look like:
'ip' => %ip,
'timestamp' => %timestamp_in_milliseconds,
'location' => array(
'coords' => array(
'latitude' => %latitude,
'longitude' => %longitude
),
'address' => array(
'city' => %city,
'country' => %country,
'country_code' => %country_code,
),
'gmtOffset' => %gmtOffset,
'dstOffset' => %dstOffset,
)