Sign up for a free account at theipapi.com to get your API key. The free plan includes 1,000 requests per month.
Use your API key to make a request to our geolocation endpoint:
curl "https://api.theipapi.com/v1/ip/8.8.8.8?api_key=YOUR_API_KEY"
The API returns JSON data with geolocation information:
{
"status": "OK",
"body": {
"asn": {
"asn": 13335,
"asn_description": "CLOUDFLARENET, US",
"country": "AU",
"created": "2010-07-15",
"network": "1.1.1.0/24",
"org_name": "Cloudflare, Inc.",
"rir": "ARIN",
"updated": "2021-07-01"
},
"company": {
"address": "101 Townsend Street, San Francisco, CA, US",
"name": "APNIC and Cloudflare DNS Resolver project",
"network": "1.1.1.0 - 1.1.1.255",
"route": "1.1.1.0/24"
},
"ip": "1.1.1.1",
"location": {
"city": "Los Angeles",
"country": "United States of America",
"country_code": "US",
"latitude": 34.052571,
"longitude": -118.243907,
"region": "California",
"timezone": "America/Los_Angeles"
},
"is_bogon": false,
"is_datacenter": false,
"is_vpn": false
},
"response_time_ms": 10
}
GET /v1/ip/{ip_address}
Returns geolocation data for a specific IP address.
ip_address
(required) - The IP address to look upapi_key
(required) - Your API keycurl "https://api.theipapi.com/v1/ip/8.8.8.8?api_key=YOUR_API_KEY"
status
- Response status ("OK" for successful requests)body.ip
- The queried IP addressbody.location.country_code
- Two-letter country codebody.location.country
- Full country namebody.location.city
- City namebody.location.region
- State/region namebody.location.latitude
- Latitude coordinatebody.location.longitude
- Longitude coordinatebody.location.timezone
- Timezone informationbody.asn.asn
- Autonomous System Numberbody.asn.org_name
- ASN organization namebody.asn.asn_description
- ASN descriptionbody.company.name
- Company namebody.company.address
- Company addressbody.is_bogon
- Whether IP is a bogon (private/invalid)body.is_datacenter
- Whether IP belongs to a datacenterbody.is_vpn
- Whether IP belongs to a VPN serviceresponse_time_ms
- API response time in millisecondsGET /v1/asn/{asn_number}
Returns information about an Autonomous System Number (ASN).
asn_number
(required) - The ASN to look upapi_key
(required) - Your API keycurl "https://api.theipapi.com/v1/asn/15169?api_key=YOUR_API_KEY"
{
"status": "OK",
"body": {
"asn": {
"asn": 15169,
"asn_description": "Google LLC",
"country": "US",
"created": "2005-11-23",
"org_name": "Google LLC",
"rir": "ARIN",
"updated": "2019-10-31"
}
},
"response_time_ms": 0
}
status
- Response status ("OK" for successful requests)body.asn.asn
- The Autonomous System Numberbody.asn.asn_description
- ASN description/namebody.asn.country
- Country code where ASN is registeredbody.asn.created
- Date when ASN was createdbody.asn.org_name
- Organization namebody.asn.rir
- Regional Internet Registry (ARIN, RIPE, APNIC, etc.)body.asn.updated
- Last update dateresponse_time_ms
- API response time in millisecondsconst https = require('https');
const options = {
hostname: 'api.theipapi.com',
path: '/v1/ip/8.8.8.8?api_key=YOUR_API_KEY',
method: 'GET'
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
const result = JSON.parse(data);
console.log(result);
});
});
req.on('error', (error) => {
console.error(error);
});
req.end();
import requests
url = "https://api.theipapi.com/v1/ip/8.8.8.8"
params = {"api_key": "YOUR_API_KEY"}
response = requests.get(url, params=params)
data = response.json()
print(data)
<?php
$url = "https://api.theipapi.com/v1/ip/8.8.8.8?api_key=YOUR_API_KEY";
$response = file_get_contents($url);
$data = json_decode($response, true);
print_r($data);
?>
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.theipapi.com/v1/ip/8.8.8.8?api_key=YOUR_API_KEY"
resp, err := http.Get(url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
var result map[string]interface{}
json.Unmarshal(body, &result)
fmt.Println(result)
}
API requests are rate limited based on your subscription plan:
Rate limits reset daily for the Free plan and monthly for paid plans. Check your usage in the dashboard.
The API returns standard HTTP status codes:
200
- Success400
- Bad Request (invalid parameters)401
- Unauthorized (invalid API key)429
- Too Many Requests (rate limit exceeded)500
- Internal Server Error{
"error": {
"code": "INVALID_API_KEY",
"message": "The provided API key is invalid"
}
}
If you need additional assistance or have questions about the API: