The DB-IP API

Backed by the continuously growing and improving DB-IP database, our online API makes it easy to use real-time IP geolocation without the need of hosting and maintaining hundreds of megabytes of data.


With the DB-IP API, your data is always up to date and our server cloud ensure that your application always gets a timely and accurate answer.


Here you will find everything you need to seamlessly integrate the DB-IP API into your application.

  1. Obtain a key
  2. Documentation
  3. PHP source code

Obtain an API key


  Free API keyLite API keyPro API keyUnlimited API key
Country
State/Province
City
Latitude/Longitude
Timezone
ISP name
Connection type*
Organization
Queries per day2,00020,000200,000unlimited
Price per month**-$16$129N/A
API Keycontact us

* when available
** for a 24-month key, approximation based on the latest exchange rates, final price is determined by PayPal



API Documentation

The DB-IP API is exposed via RESTful web services.


In order to get an answer, you need to build a valid request URL of the following form :

http://api.db-ip.com/<methodname>?<parameters>

The parameters depend on the called method, but they must always include an "api_key" element with a value equal to your API key.

The following methods are available to API clients :

  1. addrinfo : Lookup IP address information
  2. keyinfo : Get API key information

Method: addrinfo

Lookup IP address information


Method addrinfo takes two parameters :

Here is a sample URL for calling addrinfo :

http://api.db-ip.com/addrinfo?addr=173.194.67.1&api_key=123456789

The server responds with a JSON encoded object with some or all of the following properties :

Sample response using a Lite API Key :

{
"address": "173.194.67.1",
"country": "US",
"stateprov": "California",
"city": "Mountain View",
"latitude": "37.422",
"longitude": "-122.085",
"tz_offset": "-7",
"tz_name": "America/Los_Angeles"
}

Sample response using a Pro API Key :

{
"address": "173.194.67.1",
"country": "US",
"stateprov": "California",
"city": "Mountain View",
"latitude": "37.422",
"longitude": "-122.085",
"tz_offset": "-7",
"tz_name": "America/Los_Angeles",
"isp": "Google Inc.",
"ctype": "fttx",
"organization": "Google Inc.",
}

If an error occured, the server responds with an object containing only an error property with the actual error text :

{ "error": "invalid API key" }

Method: keyinfo

Get API key information


Method keyinfo takes one parameter :

Here is a sample URL for calling keyinfo :

http://api.db-ip.com/keyinfo?api_key=123456789

The server responds with a JSON encoded object with some or all of the following properties :

Sample response :

{
"api_key": "my_test_key",
"queries_per_day": "10000",
"queries_left": "2863",
"expires": "2014-05-18 17:13:33"
}


PHP source code

This package contains the core DB-IP API Client class, and sample lookup code :
search