Header

FreeIPAPI Documentation

Fast, reliable IP geolocation API with Redis + Cloudflare edge caching. Get location data for any IP address in milliseconds.

Global Coverage

Accurate geolocation data with worldwide coverage.

Lightning Fast

Edge-cached responses via Cloudflare and Redis for sub-50ms response times globally.

Secure

API key authentication with rate limiting and quota management per plan.

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header using the Bearer token format.

Authorization Header
Authorization: Bearer YOUR_API_KEY
API Key Format

All API keys start with fip_ prefix. You can create and manage your API keys from the Dashboard.

Base URL

All API requests should be made to the following base URL:

https://api.freeipapi.app

IP Lookup Endpoint

Retrieve geolocation data for any IPv4 or IPv6 address.

GET /api/v1/lookup?ip={IP_ADDRESS}

Parameters

Parameter Type Required Description
ip string No The IP address to lookup. If omitted, returns the caller's IP.

Request Format

Required Headers

Header Value Description
Authorization Bearer <api_key> Your API key with Bearer prefix
Accept application/json Response format (optional)

Response Format

Successful responses return a JSON object with geolocation data. The attribution field appears only for free tier plans.

200 OK - Success Response
{
  "ip_address": "8.8.8.8",
  "ip_version": 4,
  "is_valid": true,
  "latitude": 37.4056,
  "longitude": -122.0775,
  "country": "United States",
  "country_code": "US",
  "region": "California",
  "city": "Mountain View",
  "postal_code": "94043",
  "continent": "North America",
  "continent_code": "NA",
  "capital": "Washington D.C.",
  "phone_codes": [1],
  "timezones": ["America/Los_Angeles"],
  "languages": ["en"],
  "currencies": ["USD"],
  "asn": 15169,
  "asn_org": "Google LLC",
  "is_proxy": false
}

Error Codes

When an error occurs, the API returns an appropriate HTTP status code along with an error code and message.

HTTP Error Code Description
400 INVALID_IP The IP address format is invalid
401 MISSING_AUTH Authorization header not provided
401 INVALID_KEY API key not found or malformed
402 SUBSCRIPTION_REQUIRED No active subscription
404 IP_NOT_FOUND IP not found in database
410 KEY_REVOKED API key has been revoked
429 RATE_LIMITED Rate limit exceeded, slow down requests
429 QUOTA_EXCEEDED Monthly request limit reached
503 SERVICE_ERROR Temporary service issue, retry later
Error Response Example
{
  "error": "QUOTA_EXCEEDED",
  "message": "Monthly request limit reached. Please upgrade your plan.",
  "code": 429
}

Rate Limits

Rate limits and quotas are applied per account, not per API key. All API keys under your account share the same limits.

Plan Rate Limit Monthly Quota
Hobby 50 requests / 10 seconds 50,000 requests
Startup 100 requests / 10 seconds 2,000,000 requests
Business 1,000 requests / 10 seconds 10,000,000 requests

Rate Limit Headers

The API returns rate limit information in response headers:

Header Description
X-RateLimit-Limit Maximum requests allowed in the window
X-RateLimit-Remaining Remaining requests in current window
X-RateLimit-Reset Unix timestamp when the window resets

Field Reference

Core Fields

ip_addressstring
The queried IP address
ip_versioninteger
IP version (4 or 6)
is_validboolean
Whether the IP is valid and geolocatable
latitudenumber
Geographic latitude coordinate
longitudenumber
Geographic longitude coordinate

Location Fields

countrystring
Full country name
country_codestring
ISO 3166-1 alpha-2 country code
regionstring
State, province, or region name
citystring
City name
postal_codestring
Postal or ZIP code
continentstring
Continent name
continent_codestring
Two-letter continent code

Enrichment Fields

capitalstring
Country capital city
phone_codesarray
Country calling codes
timezonesarray
List of IANA timezone identifiers
languagesarray
List of ISO 639-1 language codes
currenciesarray
List of ISO 4217 currency codes

Network Fields

asninteger
Autonomous System Number
asn_orgstring
ASN organization name
is_proxyboolean
Whether IP is a known proxy/VPN

Code Examples

Here are code snippets for popular programming languages to help you get started quickly.

curl -s "https://api.freeipapi.app/api/v1/lookup?ip=8.8.8.8" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json"
const response = await fetch('https://api.freeipapi.app/api/v1/lookup?ip=8.8.8.8', {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Accept': 'application/json'
  }
});

const data = await response.json();
console.log(data);
import requests

response = requests.get(
    'https://api.freeipapi.app/api/v1/lookup?ip=8.8.8.8',
    headers={'Authorization': 'Bearer YOUR_API_KEY'}
)

print(response.json())
<?php
$ch = curl_init('https://api.freeipapi.app/api/v1/lookup?ip=8.8.8.8');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_API_KEY']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", 
        "https://api.freeipapi.app/api/v1/lookup?ip=8.8.8.8", nil)
    req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
    
    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
require 'net/http'
require 'json'

uri = URI('https://api.freeipapi.app/api/v1/lookup?ip=8.8.8.8')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer YOUR_API_KEY'

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
puts JSON.pretty_generate(JSON.parse(res.body))
import java.net.URI;
import java.net.http.*;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.freeipapi.app/api/v1/lookup?ip=8.8.8.8"))
            .header("Authorization", "Bearer YOUR_API_KEY")
            .GET()
            .build();
            
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
using System.Net.Http;

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");

var response = await client.GetStringAsync("https://api.freeipapi.app/api/v1/lookup?ip=8.8.8.8");
Console.WriteLine(response);

Troubleshooting

401 Unauthorized

403 Quota Exceeded

429 Rate Limited

404 IP Not Found

503 Service Error