Documentation

ipdata.co provides a JSON IP Address Geolocation API that allows you to lookup the location of any IP address, both IPv4 and IPv6.

Getting Started

The simplest call you can make would be a parameter-less GET call to the API endpoint at https://api.ipdata.co. This would return the location of the calling IP address.

curl https://api.ipdata.co?api-key=test

To lookup a specific IP Address

curl https://api.ipdata.co/8.8.8.8?api-key=test

More Examples

Javascript
Python
Node
PHP
Ruby
Go
C#
Java
Swift
Javascript
var request = new XMLHttpRequest();
request.open('GET', 'https://api.ipdata.co/?api-key=test');
request.setRequestHeader('Accept', 'application/json');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
};
request.send();
Python
from ipdata import ipdata
from pprint import pprint
# Create an instance of an ipdata object. Replace `test` with your API Key
ipdata = ipdata.IPData('test')
response = ipdata.lookup('69.78.70.144')
pprint(response)
Node
import IPData from 'ipdata';
const ipdata = new IPData('test');
const ip = '1.1.1.1';
ipdata.lookup(ip)
.then(function(data) {
console.log(data)
});
PHP
use Ipdata\ApiClient\Ipdata;
use Symfony\Component\HttpClient\Psr18Client;
use Nyholm\Psr7\Factory\Psr17Factory;
$httpClient = new Psr18Client();
$psr17Factory = new Psr17Factory();
$ipdata = new Ipdata('test', $httpClient, $psr17Factory);
$data = $ipdata->lookup('69.78.70.144');
echo json_encode($data, JSON_PRETTY_PRINT);
Ruby
require 'uri'
require 'net/http'
url = URI("https://api.ipdata.co/?api-key=test")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
Go
package main
import (
"github.com/ipdata/go"
"log"
"fmt"
)
func main() {
ipd, _ := ipdata.NewClient("test")
data, err := ipd.Lookup("8.8.8.8")
if err != nil {
log.Fatalf("%v", err)
}
fmt.Printf("%s (%s)\n", data.IP, data.ASN)
}
C#
var client = new IpDataClient("test");
// Get IP data from IP
var ipInfo = await client.Lookup("8.8.8.8");
Console.WriteLine($"Country name for {ipInfo.Ip} is {ipInfo.CountryName}");
Java
import io.ipdata.client.Ipdata;
URL url = new URL("https://api.ipdata.co");
IpdataService ipdataService = Ipdata.builder().url(url)
.key("test").get();
IpdataModel model = ipdataService.ipdata("1.1.1.1");
System.out.println(jsonSerialize(model));
Swift
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "https://api.ipdata.co/?api-key=test")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()

All calls must be made to the https endpoint. No requests will be served over unsecured HTTP.

Make sure to sign up for a Free API key here to test these examples.

The test API key used in these examples is very limited and very heavily rate limited and is meant only for a few initial tests.