An unofficial Python SDK for instantdomainsearch.com
Project description
InstantDomains SDK
An unofficial, asynchronous Python SDK for reverse-engineered endpoints of instantdomainsearch.com.
Overview
This SDK provides a simple, asynchronous client to programmatically check domain availability and get suggestions from InstantDomainSearch. It handles session initialization, cookie management, and parsing of various API responses into clean, consistent Pydantic models.
Key Features
- Asynchronous: Built with
httpxandasynciofor non-blocking I/O. - Session Management: Automatically handles session warmup and cookies to mimic a real browser session.
- Structured Output: Converts complex JSON responses into easy-to-use Pydantic models.
- Modular Design: Endpoints are organized into logical API modules (e.g.,
domain_search). - Dynamic Parsing: Includes functions to parse different API responses into a unified format.
Installation
To get started, install the pip package from PyPI:
pip install instantdomains
How It Works
InstantDomainsClient: The central entry point for the SDK. It manages thehttpx.AsyncClientinstance, base URLs, and headers.client.warmup(): A crucial first step. This method makes initial requests to the website to acquire necessary session cookies, which are required for subsequent API calls.- API Modules: Functionality is divided into modules located in
instantdomains/api/. For example, all domain searching logic is contained within theDomainSearchAPIclass, accessible viaclient.domain_search. - Pydantic Models: Each API module defines Pydantic models for its responses. The SDK ensures that no matter the structure of the raw data (HTML, JSON, etc.), the final output is always a validated and typed Pydantic object.
Quick Example
Here is a basic example of how to use the client to search for a domain's availability across several TLDs.
# InstantDomains/examples/0/runner.py
import asyncio
from instantdomains.client import InstantDomainsClient
async def main():
"""
An example of how to use the InstantDomainsClient.
"""
# Initialize the client
client = InstantDomainsClient()
try:
# It's important to run the warmup sequence to initialize the session
await client.warmup()
domain_to_check = "describemed"
# Define the TLDs you want to check
tlds_to_check = {"com", "net", "ai", "io"}
# Perform the search
search_results = await client.domain_search.search(
domain_name=domain_to_check,
tlds=tlds_to_check,
get_suggestions=True
)
print(f"Results for '{search_results.query}':")
print("\n--- Main TLDs ---")
for result in search_results.main_results:
status = "Available" if result.is_available else "Taken"
print(f"{result.domain}: {status}")
if search_results.suggested_results:
print("\n--- Suggested Domains ---")
for result in search_results.suggested_results:
status = "Available" if result.is_available else "Taken"
print(f"{result.domain}: {status}")
finally:
# Gracefully close the client session
await client.close()
if __name__ == "__main__":
asyncio.run(main())
Project Structure
The project is organized to separate concerns, with a clear distinction between the client, API logic, and data models.
instantdomains/
├── __init__.py
├── client.py # Holds the main InstantDomainsClient, session, and request logic
├── api/
│ ├── __init__.py
│ └── domain_search/
│ ├── index.py # DomainSearchAPI class with search logic
│ └── models.py # Pydantic models for domain search results
└── ...
examples/
└── 0/
└── runner.py # Example usage script
README.md # This file
requirements.txt # Project dependencies
Core Components
client.py
This file contains the InstantDomainsClient class, which is the heart of the SDK. It is responsible for:
- Managing the
httpx.AsyncClientsession. - Storing base URLs and common headers.
- Handling the session
warmup()flow for authentication. - A private
_requestmethod that centralizes error handling, logging, and execution of all HTTP requests. - Providing access to the various API modules (e.g.,
self.domain_search).
api/domain_search/
This module encapsulates all functionality related to domain searches.
index.py: Defines theDomainSearchAPIclass. It contains methods likesearch()which orchestrate calls to multiple endpoints, calculate required hashes, and use the parsing functions to process results.models.py: Defines the Pydantic models (DomainInfo,DomainSearchResults) that provide the structured output for the search results. This ensures that the user of the SDK always receives a predictable and easy-to-work-with object.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please leave issues or pull requests on the GitHub repository.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instantdomains-0.1.7.tar.gz.
File metadata
- Download URL: instantdomains-0.1.7.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49b94c1005aeaffd675cc71f9d257266dc5139b3503097cd3a66d03f22c2e117
|
|
| MD5 |
d286890560e40d5cf3bd6eb7cb6be8ce
|
|
| BLAKE2b-256 |
c1ece63f67f4f56e76010804f15dd1a06d53fed8095b099e4e89d1b0b5e225f1
|
File details
Details for the file instantdomains-0.1.7-py3-none-any.whl.
File metadata
- Download URL: instantdomains-0.1.7-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a2ddb808facc284a201e815d0fcfa4cb11b25168f1749d522e07063ac6d3548
|
|
| MD5 |
017a2dbb547fa512a7cedaf534cd2a57
|
|
| BLAKE2b-256 |
b90f5cd356c72cb544a05abbd5a4fbc60f3ffb6914c506a2212989ce4b1e2eff
|