SDKs overview

IP Geolocation offers a range of official and community-contributed Software Development Kits (SDKs) and libraries designed to facilitate integration with its API services. These SDKs abstract away the complexities of HTTP requests and JSON parsing, allowing developers to focus on utilizing IP geolocation, timezone, user agent, and VPN/proxy detection data within their applications. The available SDKs cover several popular programming languages, providing idiomatic interfaces for common API interactions. The comprehensive IP Geolocation API documentation details the various endpoints and their expected request and response structures, which the SDKs are built to align with.

Using an SDK generally simplifies the development process by handling authentication, request construction, and response deserialization. This can reduce boilerplate code and potential errors when interacting with the API. While official SDKs are directly maintained by the IP Geolocation team, community libraries offer additional language support or specialized functionalities, often maintained by independent developers.

Official SDKs by language

IP Geolocation provides official SDKs for several programming languages, ensuring direct support and compatibility with the latest API features. These SDKs are maintained to reflect updates in the API and typically offer the most stable and feature-complete integration experience. Developers can find detailed usage instructions and examples within the official IP Geolocation documentation for each SDK.

Language Package/Module Installation Command Maturity
Python ipgeolocation pip install ipgeolocation Official
PHP ipgeolocation/ipgeolocation-api composer require ipgeolocation/ipgeolocation-api Official
Node.js ipgeolocation-api npm install ipgeolocation-api Official
Ruby ipgeolocation-api-ruby gem install ipgeolocation-api-ruby Official
Go github.com/ipgeolocation/ipgeolocation-go go get github.com/ipgeolocation/ipgeolocation-go Official
Java com.ipgeolocation:ipgeolocation-java (Maven) Add to pom.xml dependencies Official
Rust ipgeolocation-rust Add to Cargo.toml dependencies Official
C# IpGeolocation.Api dotnet add package IpGeolocation.Api Official
Swift IpGeolocationSwift Add as Swift Package Dependency Official
Dart ipgeolocation_api Add to pubspec.yaml dependencies Official

Installation

Installation procedures for IP Geolocation SDKs typically follow the standard package management practices of each respective programming language. Developers will need to ensure they have the appropriate package manager installed, such as pip for Python, Composer for PHP, npm for Node.js, or Maven for Java. The following sections provide common installation commands for the primary supported languages. For more specific instructions or troubleshooting, refer to the official IP Geolocation API documentation.

Python

To install the Python SDK, use pip:

pip install ipgeolocation

PHP

For PHP projects, Composer is used:

composer require ipgeolocation/ipgeolocation-api

Node.js

Install the Node.js package via npm:

npm install ipgeolocation-api

Ruby

The Ruby gem can be installed using:

gem install ipgeolocation-api-ruby

Go

For Go projects, use the go get command:

go get github.com/ipgeolocation/ipgeolocation-go

Java

For Java, if using Maven, add the following dependency to your pom.xml:

<dependency>
    <groupId>com.ipgeolocation</groupId>
    <artifactId>ipgeolocation-java</artifactId&n>
    <version>1.0.0</version> <!-- Use the latest version -->
</dependency>

Rust

Add the following to your Cargo.toml file:

[dependencies]
ipgeolocation-rust = "0.1.0" <!-- Use the latest version -->

C#

Install the NuGet package using the .NET CLI:

dotnet add package IpGeolocation.Api

Swift

For Swift Package Manager, add the repository URL in Xcode or your Package.swift file:

.package(url: "https://github.com/ipgeolocation/ipgeolocation-api-swift.git", from: "1.0.0") <!-- Use the latest version -->

Dart

Add the dependency to your pubspec.yaml file:

dependencies:
  ipgeolocation_api: ^1.0.0 <!-- Use the latest version -->

Quickstart example

The following examples demonstrate basic usage of the IP Geolocation SDKs to retrieve geolocation information for a given IP address. An API key is required for authentication, which can be obtained from the IP Geolocation homepage after registration. These snippets illustrate how to initialize the client, make a request, and access the parsed response data. For more advanced features, such as batch requests, timezone lookups, or user agent parsing, consult the IP Geolocation API reference.

Python Quickstart

This Python example fetches geolocation data for a specified IP address. Ensure your API key is configured.

from ipgeolocation.api import IPGeolocationAPI

# Replace with your actual API key
API_KEY = "YOUR_API_KEY"

# Initialize the client
ip_geolocation_api = IPGeolocationAPI(api_key=API_KEY)

# Get geolocation data for an IP address (or leave empty for current IP)
ip_address = "8.8.8.8" # Example: Google DNS IP
response = ip_geolocation_api.get_ip_geolocation(ip_address=ip_address)

if response.status_code == 200:
    data = response.json()
    print(f"IP: {data.get('ip')}")
    print(f"Country: {data.get('country_name')}")
    print(f"City: {data.get('city')}")
    print(f"Latitude: {data.get('latitude')}, Longitude: {data.get('longitude')}")
else:
    print(f"Error: {response.status_code} - {response.text}")

PHP Quickstart

This PHP example uses the Composer-installed library to query geolocation data. Replace YOUR_API_KEY with your API key.

<?php
require_once 'vendor/autoload.php';

use IPGeolocationAPI\IPGeolocationAPI;

// Replace with your actual API key
$apiKey = "YOUR_API_KEY";

// Initialize the client
$ipGeolocationApi = new IPGeolocationAPI($apiKey);

// Get geolocation data for an IP address
$ipAddress = "8.8.8.8"; // Example: Google DNS IP
$response = $ipGeolocationApi->getGeolocation($ipAddress);

if ($response->getStatus() == 200) {
    $data = $response->json();
    echo "IP: " . $data->ip . "\n";
    echo "Country: " . $data->country_name . "\n";
    echo "City: " . $data->city . "\n";
    echo "Latitude: " . $data->latitude . ", Longitude: " . $data->longitude . "\n";
} else {
    echo "Error: " . $response->getStatus() . " - " . $response->getBody() . "\n";
}
?>

Node.js Quickstart

This Node.js example demonstrates fetching IP geolocation. Ensure you have installed the ipgeolocation-api package.

const IPGeolocationAPI = require('ipgeolocation-api');

// Replace with your actual API key
const API_KEY = "YOUR_API_KEY";

// Initialize the client
const ipgeolocationApi = new IPGeolocationAPI(API_KEY);

// Get geolocation data for an IP address
const ipAddress = "8.8.8.8"; // Example: Google DNS IP
ipgeolocationApi.getGeolocation(ipAddress, (response) => {
    if (response.status === 200) {
        const data = JSON.parse(response.body);
        console.log(`IP: ${data.ip}`);
        console.log(`Country: ${data.country_name}`);
        console.log(`City: ${data.city}`);
        console.log(`Latitude: ${data.latitude}, Longitude: ${data.longitude}`);
    } else {
        console.error(`Error: ${response.status} - ${response.body}`);
    }
});

Community libraries

In addition to the official SDKs, the IP Geolocation ecosystem may include community-maintained libraries and integrations. These libraries, developed by third-party contributors, can offer alternative approaches, support for less common languages, or specialized features not found in the official offerings. While community libraries can provide valuable flexibility, their support and maintenance levels can vary. Developers considering a community library should verify its active maintenance, documentation, and compatibility with the latest API version by reviewing its project repository, often hosted on platforms like GitHub. The Mozilla Developer Network's definition of open-source software provides context for understanding community-driven projects.

Examples of potential community contributions might include:

  • Lightweight clients for specific frameworks (e.g., a Django package or a Laravel package).
  • Wrappers for niche programming languages.
  • Integrations with other services or data visualization tools.
  • Command-line interface (CLI) tools for quick lookups.

It is recommended to check the official IP Geolocation website or community forums for links to any recommended or widely used third-party libraries. When using community libraries, developers are responsible for assessing their security, stability, and adherence to API best practices. Community-driven development is a common practice in the API landscape, as evidenced by the numerous Google Maps Platform client libraries developed by third parties.