Documentation

ipdata.co provides a RESTful 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
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();
import requests
payload = {"api-key": "test"}
response = requests.get('https://api.ipdata.co', params=payload).json()
print(response)
var request = require('request');
request({
method: 'GET',
url: 'https://api.ipdata.co/?api-key=test',
headers: {
'Accept': 'application/json'
}}, function (error, response, body) {
console.log('Status:', response.statusCode);
console.log('Headers:', JSON.stringify(response.headers));
console.log('Response:', body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.ipdata.co/?api-key=test",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
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
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.ipdata.co/?api-key=test"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
var client = new RestClient("https://api.ipdata.co/?api-key=test");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
HttpResponse<String> response = Unirest.get("https://api.ipdata.co/?api-key=test")
.header("Cache-Control", "no-cache")
.header("Postman-Token", "9d13234d-786c-49aa-bcdb-c9d2f1c06940")
.asString();
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.