Getting started overview

This guide provides a structured approach to initiating development with ipapi.com, focusing on the essential steps required to make a successful API call. The process primarily involves account creation, API key retrieval, and the construction of a basic request. ipapi.com is designed to provide IP geolocation data, including country, city, region, and other related information, through a RESTful API interface ipapi.com documentation. Understanding the fundamental principles of RESTful APIs, such as HTTP methods and status codes, can be beneficial for integration Mozilla's REST API guide.

The core functionality of ipapi.com revolves around querying an IP address to receive a JSON-formatted response containing its geographical and network details. This process is consistent across various programming languages, as the underlying interaction is based on standard HTTP requests. Developers can choose from a range of supported SDKs, including PHP, Python, Ruby, Node.js, Go, Java, C#, and Perl, which abstract some of the HTTP request complexities, though direct HTTP calls are also fully supported.

Before proceeding with API calls, it is important to review the service's terms and conditions, especially regarding usage limits and data privacy. ipapi.com offers a free tier that allows up to 1,000 requests per month, which is suitable for initial testing and small-scale applications ipapi.com pricing page. For higher volumes, paid plans are available, starting at $10 per month for 10,000 requests.

Here's a quick reference table outlining the initial steps:

Step What to do Where
1. Sign Up Create a new account on the ipapi.com website. ipapi.com homepage
2. Get API Key Locate your unique API access key in your account dashboard. ipapi.com dashboard (after login)
3. Construct Request Formulate an HTTP GET request to the API endpoint with your key. Your code editor / Terminal (cURL)
4. Parse Response Process the JSON data returned by the API. Your application logic

Create an account and get keys

To access the ipapi.com API, the first prerequisite is to establish an account. This process typically involves providing an email address and creating a password. Upon successful registration, users are granted access to a personal dashboard, which serves as the central hub for managing API access.

  1. Navigate to the ipapi.com homepage: Open your web browser and go to ipapi.com.
  2. Initiate the registration process: Look for a "Sign Up" or "Get API Key" button, usually prominent on the homepage.
  3. Complete the registration form: Provide the requested information, which typically includes an email address and a password. You may also need to agree to the terms of service.
  4. Verify your email (if required): Some services send a verification email to confirm your address. Follow the instructions in the email to activate your account.
  5. Access your dashboard: Once registered and logged in, you will be redirected to your personal dashboard.
  6. Locate your API key: Within the dashboard, there will be a section clearly labeled "API Key," "Access Key," or similar. This is a unique alphanumeric string that authenticates your requests to the ipapi.com API. It is crucial to keep this key confidential to prevent unauthorized usage.

The API key acts as a credential that authorizes your application to interact with the ipapi.com services RFC 6750 on Bearer Token Usage. Without a valid API key, requests will generally be rejected with an authentication error. It's recommended to store your API key securely, avoiding hardcoding it directly into client-side code, especially for production environments.

Your first request

After obtaining your API key, you can proceed to make your first API call. The ipapi.com API is a RESTful service, meaning you interact with it using standard HTTP methods, primarily GET requests, to specific endpoints. The base URL for the API is http://api.ipapi.com/.

To perform a basic IP lookup, you will append the IP address you wish to query and your API key to the base URL. For example, to look up the IP address 8.8.8.8 (Google's public DNS server), the request structure would be as follows:

http://api.ipapi.com/8.8.8.8?access_key=YOUR_API_KEY

Replace YOUR_API_KEY with the actual API key you retrieved from your dashboard.

Using cURL (Command Line)

cURL is a command-line tool and library for transferring data with URLs. It's an excellent way to test API endpoints quickly without writing any code.

curl "http://api.ipapi.com/8.8.8.8?access_key=YOUR_API_KEY"

Executing this command in your terminal will return a JSON object containing the geolocation data for 8.8.8.8.

Using Python

Python's requests library simplifies making HTTP requests. First, ensure you have it installed: pip install requests.

import requests
import json

api_key = "YOUR_API_KEY" # Replace with your actual API key
ip_address = "8.8.8.8"
url = f"http://api.ipapi.com/{ip_address}?access_key={api_key}"

try:
    response = requests.get(url)
    response.raise_for_status() # Raise an exception for HTTP errors (4xx or 5xx)
    data = response.json()
    print(json.dumps(data, indent=4))
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

Using Node.js

You can use the built-in https module or a library like axios for Node.js. Here's an example using axios (install with: npm install axios).

const axios = require('axios');

const apiKey = "YOUR_API_KEY"; // Replace with your actual API key
const ipAddress = "8.8.8.8";
const url = `http://api.ipapi.com/${ipAddress}?access_key=${apiKey}`;

axios.get(url)
  .then(response => {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch(error => {
    console.error(`Error: ${error.message}`);
    if (error.response) {
      console.error(`Status: ${error.response.status}`);
      console.error(`Data: ${JSON.stringify(error.response.data, null, 2)}`);
    }
  });

Upon a successful request, the API will return a JSON object similar to this (actual data may vary):

{
    "ip": "8.8.8.8",
    "hostname": "dns.google",
    "continent_code": "NA",
    "continent_name": "North America",
    "country_code": "US",
    "country_name": "United States",
    "region_code": "VA",
    "region_name": "Virginia",
    "city": "Ashburn",
    "zip": "20147",
    "latitude": 39.0437,
    "longitude": -77.4875,
    "location": {
        "geoname_id": 4744047,
        "capital": "Washington D.C.",
        "languages": [
            {
                "code": "en",
                "name": "English",
                "native": "English"
            }
        ],
        "country_flag": "https://assets.ipapi.com/flags/us.svg",
        "country_flag_emoji": "πŸ‡ΊπŸ‡Έ",
        "country_flag_emoji_unicode": "U+1F1FA U+1F1F8",
        "calling_code": "1",
        "is_eu": false
    },
    "time_zone": {
        "id": "America/New_York",
        "current_time": "2026-05-29T10:30:00-04:00",
        "gmt_offset": -14400,
        "code": "EDT",
        "is_daylight_saving": true
    },
    "currency": {
        "code": "USD",
        "name": "US Dollar",
        "plural": "US dollars",
        "symbol": "$",
        "symbol_native": "$"
    },
    "connection": {
        "asn": 15169,
        "isp": "Google LLC"
    },
    "security": {
        "is_proxy": false,
        "proxy_type": null,
        "is_crawler": false,
        "crawler_name": null,
        "crawler_type": null,
        "is_tor": false,
        "threat_level": "low",
        "threat_types": null
    }
}

Common next steps

After successfully making your first API call, consider these next steps to further integrate ipapi.com into your applications:

  • Dynamic IP Lookups: Instead of hardcoding an IP address, integrate logic to dynamically retrieve the user's IP address (e.g., from request headers in a web application) and pass it to the ipapi.com API.
  • Error Handling: Implement robust error handling to gracefully manage scenarios such as invalid API keys, rate limit exceeded errors, or network issues. The API returns specific error codes and messages that can be parsed to provide user-friendly feedback or trigger retry mechanisms.
  • Data Parsing and Utilization: Explore the full range of data fields returned by the API (e.g., city, country_name, latitude, longitude, time_zone, connection.isp). Integrate this data into your application logic for purposes such as content localization, fraud detection, or analytics.
  • Utilize SDKs: For supported languages (PHP, Python, Ruby, Node.js, Go, Java, C#, Perl), consider using the official ipapi.com SDKs. These SDKs often simplify API interaction by handling request construction, response parsing, and error management, reducing boilerplate code. Refer to the ipapi.com documentation for SDK specifics.
  • Caching: For frequently requested IP addresses or static content based on geolocation, implement caching strategies to reduce the number of API calls and improve application performance. Be mindful of the data's freshness requirements.
  • Authentication Best Practices: For production environments, ensure your API key is stored securely, perhaps using environment variables or a secrets management service, rather than directly in your codebase.
  • Explore Advanced Features: Review the ipapi.com documentation for any advanced features or specific endpoints that might be relevant to your use case, such as bulk IP lookups or specific data fields.
  • Monitor Usage: Regularly check your API usage statistics in the ipapi.com dashboard to stay within your plan limits and anticipate when an upgrade might be necessary.

Troubleshooting the first call

Encountering issues during your first API call is common. Here are some typical problems and their solutions:

  • Invalid API Key:

    • Symptom: API returns an error message indicating an invalid or missing access key (e.g., {"success":false,"error":{"code":101,"type":"missing_access_key","info":"You have not supplied an API Access Key."}}).
    • Solution: Double-check that you have copied your API key correctly from your ipapi.com dashboard. Ensure there are no leading or trailing spaces. Verify it is included as the access_key parameter in your request URL.
  • Rate Limit Exceeded:

    • Symptom: API returns an error indicating that the request limit has been reached (e.g., {"success":false,"error":{"code":104,"type":"usage_limit_reached","info":"Your monthly API request volume has been reached."}}).
    • Solution: If you are on the free tier, you might have exceeded the 1,000 requests/month limit. Check your usage statistics in the ipapi.com dashboard. Wait for the next billing cycle, or consider upgrading your plan ipapi.com pricing options.
  • Incorrect Endpoint or IP Address Format:

    • Symptom: The API returns a 404 Not Found error or an error related to an invalid IP address.
    • Solution: Verify that the base URL is http://api.ipapi.com/ and that the IP address is correctly formatted and appended directly after the base URL (e.g., http://api.ipapi.com/8.8.8.8).
  • Network Connectivity Issues:

    • Symptom: Your application receives a network error (e.g., connection refused, timeout) before even getting an API response.
    • Solution: Check your internet connection. Ensure no firewalls or proxies are blocking outgoing HTTP/HTTPS requests from your development environment. Try accessing the URL directly in a web browser (with your API key) to confirm the API is reachable.
  • JSON Parsing Errors:

    • Symptom: Your code fails to parse the API response, indicating malformed JSON.
    • Solution: This typically occurs if the API returned an error message in a different format or if the response was truncated. First, verify the API call was successful (HTTP status code 200). If it was, ensure your JSON parsing library is configured correctly to handle the response.
  • HTTP vs. HTTPS:

    • Symptom: Connection errors or warnings related to insecure connections.
    • Solution: While the basic examples use HTTP, it's generally recommended to use HTTPS for all API calls in production environments for security. ipapi.com supports HTTPS, so you would use https://api.ipapi.com/. Ensure your client library supports HTTPS.