SDKs overview
IP2WHOIS Information Lookup offers a suite of official Software Development Kits (SDKs) designed to streamline integration with its WHOIS API. These SDKs provide language-specific interfaces for accessing domain registration information, including registrant details, creation and expiration dates, and nameserver records. By encapsulating HTTP requests and JSON parsing, the SDKs aim to reduce development effort and potential errors associated with direct API consumption. Developers can utilize these libraries to embed WHOIS lookup capabilities into a variety of applications, ranging from cybersecurity tools to domain management platforms. The availability of SDKs across multiple popular programming languages facilitates broader adoption and easier integration into existing software ecosystems. For a comprehensive overview of the API and its capabilities, refer to the IP2WHOIS developer documentation.
The core functionality of these SDKs revolves around querying the IP2WHOIS API to retrieve structured WHOIS data. This typically involves passing a domain name or IP address to a client method, which then handles the communication with the API endpoint and returns the parsed results. The design often follows common patterns for API clients, emphasizing ease of use and adherence to language-specific conventions. For example, a Python SDK might expose methods that feel idiomatic to Python developers, while a Java SDK would integrate seamlessly into Java projects.
Official SDKs by language
IP2WHOIS provides official SDKs for a range of programming languages, ensuring broad compatibility and ease of integration for developers. These libraries are maintained by IP2WHOIS and are the recommended method for interacting with their API. Each SDK is tailored to the conventions and package management systems of its respective language, simplifying installation and usage. The following table summarizes the key official SDKs available:
| Language | Package/Library | Installation Command | Maturity |
|---|---|---|---|
| PHP | ip2whois/ip2whois-php |
composer require ip2whois/ip2whois-php |
Stable |
| Python | ip2whois |
pip install ip2whois |
Stable |
| Ruby | ip2whois |
gem install ip2whois |
Stable |
| Java | com.ip2whois:ip2whois-java |
Add to pom.xml (Maven) or build.gradle (Gradle) |
Stable |
| Node.js | @ip2whois/ip2whois-nodejs |
npm install @ip2whois/ip2whois-nodejs |
Stable |
| .NET | IP2WHOIS.IP2WHOIS-dotnet |
Install-Package IP2WHOIS.IP2WHOIS-dotnet |
Stable |
| Go | github.com/ip2whois/ip2whois-go |
go get github.com/ip2whois/ip2whois-go |
Stable |
Each SDK is designed to abstract the HTTP request and response handling, allowing developers to focus on integrating WHOIS data into their application logic. These official libraries are regularly updated to reflect any API changes and ensure compatibility with the latest language versions. The use of standard package managers for each language (e.g., Composer for PHP, pip for Python, npm for Node.js) simplifies dependency management and installation processes, aligning with modern software development practices as outlined in various HTTP status code guides.
Installation
Installing the IP2WHOIS SDKs typically involves using the standard package manager for your chosen programming language. Below are detailed installation instructions for each officially supported language:
PHP
For PHP projects, the IP2WHOIS SDK is distributed via Composer, the dependency manager for PHP. Ensure Composer is installed on your system.
composer require ip2whois/ip2whois-php
After installation, you can include the autoloader in your PHP script:
require 'vendor/autoload.php';
Python
The Python SDK is available on PyPI and can be installed using pip, Python's package installer. This is a common practice for Python package management.
pip install ip2whois
Ruby
For Ruby applications, the IP2WHOIS gem is distributed through RubyGems. Use the gem command to install it.
gem install ip2whois
Java
The Java SDK can be integrated into your project using build automation tools like Maven or Gradle. Add the dependency to your pom.xml (for Maven) or build.gradle (for Gradle) file.
Maven (pom.xml)
<dependency>
<groupId>com.ip2whois</groupId>
<artifactId>ip2whois-java</artifactId>
<version>1.0.0</version> <!-- Replace with the latest version -->
</dependency>
Gradle (build.gradle)
implementation 'com.ip2whois:ip2whois-java:1.0.0' <!-- Replace with the latest version -->
Node.js
The Node.js SDK is published on npm, the package manager for JavaScript. Install it using npm or yarn.
npm install @ip2whois/ip2whois-nodejs
# or
yarn add @ip2whois/ip2whois-nodejs
.NET
For .NET projects, the SDK is available as a NuGet package. Use the NuGet Package Manager Console to install it.
Install-Package IP2WHOIS.IP2WHOIS-dotnet
Alternatively, you can use the dotnet add package command for .NET Core projects:
dotnet add package IP2WHOIS.IP2WHOIS-dotnet
Go
The Go SDK can be installed using the go get command, which fetches the module from its repository.
go get github.com/ip2whois/ip2whois-go
Ensure your Go environment is properly configured, including GOPATH and GO111MODULE settings, for successful dependency management.
Quickstart example
This section provides a quickstart example using the Python SDK to demonstrate how to retrieve WHOIS information for a domain. Similar patterns apply to other language SDKs, differing primarily in syntax and object instantiation.
Python Quickstart
First, ensure you have installed the Python SDK as described in the Installation section. You will also need an API key from your IP2WHOIS account.
import ip2whois
# Replace 'YOUR_API_KEY' with your actual IP2WHOIS API key
api_key = 'YOUR_API_KEY'
# Initialize the IP2WHOIS client
client = ip2whois.Client(api_key)
# Define the domain to look up
domain_name = 'example.com'
try:
# Perform the WHOIS lookup
whois_record = client.lookup(domain_name)
# Print some key information from the WHOIS record
print(f"Domain: {whois_record.domain.name}")
print(f"Registrar: {whois_record.registrar.name}")
print(f"Creation Date: {whois_record.creation_date}")
print(f"Expiration Date: {whois_record.expiration_date}")
print(f"Domain Status: {', '.join(whois_record.domain.status)}")
# Accessing registrant contact information (if available and allowed by GDPR)
if whois_record.registrant and whois_record.registrant.name:
print(f"Registrant Name: {whois_record.registrant.name}")
if whois_record.registrant and whois_record.registrant.email:
print(f"Registrant Email: {whois_record.registrant.email}")
except ip2whois.exceptions.APIError as e:
print(f"API Error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
This Python example demonstrates:
- Importing the necessary
ip2whoislibrary. - Initializing the client with your API key.
- Calling the
lookup()method with a target domain. - Accessing various attributes of the returned
whois_recordobject, such as domain name, registrar, and dates. - Basic error handling for API-specific and general exceptions.
Note that due to privacy regulations like GDPR, certain registrant contact details may be redacted or anonymized in WHOIS records. The IP2WHOIS API and its SDKs reflect these data availability constraints.
Community libraries
While IP2WHOIS provides a comprehensive set of official SDKs, the API's straightforward RESTful design also allows for direct HTTP integration using standard client libraries available in virtually any programming language. This has led to the potential for community-contributed libraries, though there is no single aggregated list of officially recognized third-party SDKs on the IP2WHOIS developer portal. Developers often opt to build custom wrappers or use generic HTTP client libraries (e.g., requests in Python, axios in Node.js, Guzzle in PHP) to interact with the API when an official SDK for a specific niche requirement isn't available or when greater control over the HTTP request is desired.
When considering community-developed libraries, it is important to evaluate their maintenance status, adherence to the latest OpenAPI specification, and community support. Developers should refer to the official IP2WHOIS API documentation for the most accurate and up-to-date API specifications, regardless of whether an official or community library is used. This ensures compatibility and proper handling of API responses, including understanding rate limits and error codes, which are crucial for stable application development.
For direct API interaction, developers can construct HTTP GET requests to the IP2WHOIS endpoint, passing the domain and API key as query parameters. For example, a basic request might look like https://api.ip2whois.com/v2?key=YOUR_API_KEY&domain=example.com. The response is typically in JSON format, which can then be parsed using the language's built-in JSON deserialization capabilities. This method offers maximum flexibility but requires manual handling of request construction, error codes, and response parsing, tasks that the official SDKs automate.