A simple REST API to check domain name availability using WHOIS and DNS lookups.
- Check domain availability using WHOIS records
- Verify domain status through DNS resolution
- Combined status check using both methods
- Support for custom TLDs (Top Level Domains)
- Optional rate limiting to prevent abuse
- Response caching for improved performance
- Configurable timeouts for WHOIS and DNS checks
- Bulk domain checking
- Metrics and health monitoring
- Simple REST API interface
- Comprehensive test suite
- CI/CD with GitHub Actions
- Nixpacks compatibility for easy deployment
GET /?domain=example[&tld=com]
domain(required): The domain name to check (without TLD)tld(optional): The top-level domain to check (default: "com")
{
"domain": "example.com",
"status": "taken|available",
"whois": {
"status": "taken|available|error|timeout",
"expiration_date": "2024-12-31", // Only for taken domains
"registrar": "Example Registrar" // Only for taken domains
},
"dns": {
"status": "taken|available|error|timeout",
"ip": "93.184.216.34" // Only for taken domains
},
"tld": "com",
"response_time": "0.82s"
}POST /bulk
Content-Type: application/json
{
"domains": [
{"domain": "example", "tld": "com"},
{"domain": "example", "tld": "org"},
{"domain": "example"}
]
}
- Maximum 10 domains per request
- Rate limited to 5 requests per minute (when rate limiting is enabled)
GET /health
Response:
{
"status": "healthy",
"timestamp": "2024-03-20T10:30:00Z",
"version": "1.0.0",
"rate_limiting": true,
"timeouts": {
"whois": "5s",
"dns": "3s"
}
}GET /metrics
Response:
{
"cache_stats": {
"cache_hits": 150,
"cache_misses": 50
},
"uptime": "2024-03-20T10:00:00Z",
"rate_limiting_enabled": true
}The project includes an example.env file with default values and detailed comments. Copy this file to .env to get started:
cp example.env .envKey environment variables:
| Variable | Description | Default | Example |
|---|---|---|---|
ENABLE_RATE_LIMITS |
Enable/disable rate limiting | true |
false |
REDIS_URL |
Redis URL for rate limiting | None |
redis://localhost:6379/0 |
CACHE_TYPE |
Cache storage type | simple |
redis |
CACHE_REDIS_URL |
Redis URL for caching | None |
redis://localhost:6379/1 |
WHOIS_TIMEOUT |
Timeout for WHOIS queries in seconds | 5 |
10 |
DNS_TIMEOUT |
Timeout for DNS queries in seconds | 3 |
5 |
PORT |
Port to run the server on | 5000 |
8080 |
FLASK_ENV |
Flask environment | production |
development |
CACHE_TIMEOUT |
Cache duration in seconds | 300 |
600 |
MAX_BULK_DOMAINS |
Max domains in bulk request | 10 |
20 |
See example.env for all available options and detailed comments.
The API supports two storage backends for rate limiting:
-
Redis (Recommended for production):
- Set
REDIS_URLto your Redis instance - Example:
REDIS_URL=redis://localhost:6379/0 - Provides persistent and distributed rate limiting
- Set
-
Memory (Development only):
- Used when
REDIS_URLis not set - Not suitable for production
- Data is lost on server restart
- Used when
Two caching backends are available:
-
Simple (Default):
- Set
CACHE_TYPE=simple - In-memory caching
- Suitable for development
- Set
-
Redis:
- Set
CACHE_TYPE=redis - Set
CACHE_REDIS_URLto your Redis instance - Recommended for production
- Provides distributed caching
- Set
- Single domain check: 10 requests per minute
- Bulk check: 5 requests per minute
- Overall: 100 requests per day
- Health and metrics endpoints: unlimited
Results are cached for 5 minutes to improve performance and reduce load on WHOIS servers.
- Install dependencies:
pip install -r requirements.txt- Run the development server:
python script.pyThe API will be available at http://localhost:3000
Run the test suite:
# Run tests
pytest test_script.py -v
# Run tests with coverage report
pytest test_script.py -v --cov=scriptThe test suite includes:
- Health check endpoint testing
- Metrics endpoint testing
- Known domain checks (google.com, facebook.com)
- Invalid domain handling
- Bulk domain checking
- Custom TLD support
This project is ready to deploy to platforms like Railway or Dokploy using Nixpacks.
- Python 3.x
- Dependencies listed in requirements.txt
- Clone this repository
- Configure environment variables if needed
- Connect your repository to Railway/Dokploy
- The platform will automatically:
- Detect the Python project
- Use Nixpacks for building
- Install dependencies
- Start the application using gunicorn
You can also build the application manually using Nixpacks:
# Install Nixpacks
curl -sSL https://nixpacks.com/install.sh | bash
# Build the application
nixpacks build . --name domain-check-apiThe project includes GitHub Actions workflows that:
- Run the test suite
- Generate coverage reports
- Build the application using Nixpacks
- Deploy on successful builds (when configured)
MIT License