SDKs overview

HackMyIP offers a suite of Software Development Kits (SDKs) designed to simplify interaction with its IP Geolocation, VPN/Proxy Detection, and Threat Intelligence APIs. These SDKs provide language-specific interfaces, abstracting the underlying HTTP requests and JSON response parsing, allowing developers to integrate IP data services into their applications more efficiently. The official SDKs support several popular programming languages, with community-contributed libraries potentially extending support to others. The primary goal of these SDKs is to reduce development time and potential errors when consuming the HackMyIP API endpoints.

Integrating an API using an SDK typically involves installing the library via a package manager, configuring it with an API key, and then calling specific methods to retrieve data. This approach is often preferred over making raw HTTP requests, particularly for developers who want to focus on application logic rather than API communication specifics. The HackMyIP API documentation provides comprehensive details on endpoint structures and expected responses, which the SDKs are built to encapsulate.

While SDKs streamline API access, understanding fundamental web technologies like HTTP methods (GET, POST) and JSON data structures remains beneficial for debugging and advanced use cases. The Hypertext Transfer Protocol (HTTP/1.1) specification defines the core communication protocol, and JSON (JavaScript Object Notation) is a widely adopted data interchange format used by the HackMyIP API.

Official SDKs by language

HackMyIP provides official SDKs for a range of programming languages, ensuring broad compatibility for developers. These SDKs are maintained by HackMyIP and are the recommended method for integrating with their API. Each SDK is designed to align with the idiomatic practices of its respective language, offering a natural development experience.

Language Package Manager / Name Installation Command Maturity Documentation Link
PHP Composer (hackmyip/php-sdk) composer require hackmyip/php-sdk Stable HackMyIP PHP SDK Documentation
Python pip (hackmyip-python) pip install hackmyip-python Stable HackMyIP Python SDK Documentation
Ruby RubyGems (hackmyip-ruby) gem install hackmyip-ruby Stable HackMyIP Ruby SDK Documentation
Node.js npm (@hackmyip/node-sdk) npm install @hackmyip/node-sdk Stable HackMyIP Node.js SDK Documentation
Go Go Modules (github.com/hackmyip/go-sdk) go get github.com/hackmyip/go-sdk Stable HackMyIP Go SDK Documentation
Java Maven/Gradle (com.hackmyip:java-sdk) (See docs for Maven/Gradle snippet) Stable HackMyIP Java SDK Documentation
C# NuGet (HackMyIP.CSharp.SDK) dotnet add package HackMyIP.CSharp.SDK Stable HackMyIP C# SDK Documentation

Installation

Installing HackMyIP SDKs typically involves using the standard package manager for your chosen programming language. This process fetches the library and its dependencies, making it available for use in your project. An active internet connection is usually required for the initial installation.

PHP (Composer)

Ensure you have Composer installed. Navigate to your project directory and run:

composer require hackmyip/php-sdk

Python (pip)

Ensure you have pip installed. Run the following command in your terminal:

pip install hackmyip-python

Ruby (RubyGems)

Ensure you have RubyGems installed. Run the following command:

gem install hackmyip-ruby

Node.js (npm)

Ensure you have Node.js and npm installed. Navigate to your project directory and run:

npm install @hackmyip/node-sdk

Go (Go Modules)

Ensure you have Go installed and your project is using Go Modules. Run:

go get github.com/hackmyip/go-sdk

Java (Maven/Gradle)

For Java, you'll typically add a dependency to your pom.xml (Maven) or build.gradle (Gradle) file. Refer to the HackMyIP Java SDK documentation for the exact dependency snippet.

C# (.NET CLI / NuGet)

Ensure you have the .NET SDK installed. Navigate to your project directory and run:

dotnet add package HackMyIP.CSharp.SDK

Quickstart example

This section provides a basic quickstart example for retrieving IP geolocation data using the HackMyIP SDKs. For more detailed examples and advanced features like VPN/proxy detection or threat intelligence, refer to the official HackMyIP API documentation.

Python Example

This example demonstrates how to use the Python SDK to get geolocation data for a specific IP address.

from hackmyip import HackMyIP

# Replace 'YOUR_API_KEY' with your actual HackMyIP API key
api_key = "YOUR_API_KEY"
client = HackMyIP(api_key)

# IP address to lookup
ip_address = "8.8.8.8" # Google DNS IP

try:
    response = client.get_ip_info(ip_address)
    if response.get("status") == "success":
        print(f"IP: {response.get('ip')}")
        print(f"Country: {response.get('country_name')}")
        print(f"City: {response.get('city')}")
        print(f"Latitude: {response.get('latitude')}")
        print(f"Longitude: {response.get('longitude')}")
        print(f"ISP: {response.get('isp')}")
    else:
        print(f"Error: {response.get('message', 'Unknown error')}")
except Exception as e:
    print(f"An error occurred: {e}")

Node.js Example

This example shows how to perform an IP lookup using the Node.js SDK.

const HackMyIP = require('@hackmyip/node-sdk');

// Replace 'YOUR_API_KEY' with your actual HackMyIP API key
const apiKey = 'YOUR_API_KEY';
const client = new HackMyIP(apiKey);

// IP address to lookup
const ipAddress = '1.1.1.1'; // Cloudflare DNS IP

client.getIpInfo(ipAddress)
  .then(response => {
    if (response.status === 'success') {
      console.log(`IP: ${response.ip}`);
      console.log(`Country: ${response.country_name}`);
      console.log(`City: ${response.city}`);
      console.log(`Latitude: ${response.latitude}`);
      console.log(`Longitude: ${response.longitude}`);
      console.log(`Organization: ${response.organization}`);
    } else {
      console.error(`Error: ${response.message || 'Unknown error'}`);
    }
  })
  .catch(error => {
    console.error(`An error occurred: ${error.message}`);
  });

PHP Example

Here's a PHP example for fetching IP information.

<?php
require_once 'vendor/autoload.php'; // Adjust path if necessary

use HackMyIP\HackMyIP;

// Replace 'YOUR_API_KEY' with your actual HackMyIP API key
$apiKey = 'YOUR_API_KEY';
$client = new HackMyIP($apiKey);

// IP address to lookup
$ipAddress = '8.8.4.4'; // Google DNS IP

try {
    $response = $client->getIpInfo($ipAddress);

    if (isset($response['status']) && $response['status'] === 'success') {
        echo "IP: " . $response['ip'] . "\n";
        echo "Country: " . $response['country_name'] . "\n";
        echo "City: " . $response['city'] . "\n";
        echo "Latitude: " . $response['latitude'] . "\n";
        echo "Longitude: " . $response['longitude'] . "\n";
        echo "Timezone: " . $response['timezone'] . "\n";
    } else {
        echo "Error: " . ($response['message'] ?? 'Unknown error') . "\n";
    }
} catch (Exception $e) {
    echo "An error occurred: " . $e->getMessage() . "\n";
}
?>

Community libraries

While HackMyIP provides official SDKs, the open-source community may develop and maintain additional libraries or integrations for languages not officially supported, or offer alternative implementations. These community-driven projects can be found on platforms like GitHub, GitLab, or language-specific package repositories. Always exercise caution when using community libraries:

  • Verification: Check the project's activity, recent commits, and issue tracker.
  • Security: Review the code for potential vulnerabilities before integrating it into production systems.
  • Documentation: Ensure the library has clear and sufficient documentation for usage and troubleshooting.
  • Maintenance: Assess whether the library is actively maintained and compatible with the latest API versions.

Searching for hackmyip client or hackmyip sdk on GitHub topics can help identify community contributions. If no suitable community library exists for a specific language, developers can directly interact with the HackMyIP REST API using standard HTTP client libraries available in virtually all programming languages, such as requests in Python or fetch in JavaScript.

Direct API integration requires handling aspects like API key management, rate limiting, error handling, and JSON parsing manually. For example, a developer might use a library like Fetch API in JavaScript to make direct HTTP requests to the HackMyIP endpoint.