Online API

Zero maintenance and always up to date.

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.

Every day, our API servers answer millions of queries from thousands of users, and our cloud infrastructure ensures that they always get a timely and up to date answer.

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



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$126N/A
API Keyfree keybuy keybuy 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 :

addr
The IPv4 or IPv6 address to look up
api_key
Your API key

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 :

address
The requested IP address
country
Two-letters country code
stateprov
Name of state or province
city
City name
latitude
Decimal latitude
longitude
Decimal longitude
tz_offset
Offset from UTC in hours
tz_name
Name of timezone
isp
Internet Service Provider name
ctype
Connection type
organization
Organization name

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 :

api_key
Your API key

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 :

api_key
Your API key
queries_per_day
Numbers of IP address queries per day allowed by your API key
queries_left
Number of IP address queries left for the day
expires
You API key expiration date and time (format is YYYY-MM-DD HH:MM:SS and timezone is UTC)

Sample response :

{
"api_key": "my_test_key",
"queries_per_day": "10000",
"queries_left": "2863",
"expires": "2015-10-02 16:25:59"
}


PHP source code

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