Introduction
The Domains Reseller API allows you to connect and interact with our system using your own system. Using the API, you are able to perform actions such as:
- Register a domain under your account
- Transfer a domain from another company to your account
- Renew a domain under your account
- Release a domain that has a registrar lock for a domain registered under your account
- Modify Contact Details of a domain registered under your account
- Get the EPP Code of a domain registered under your account
- Get/Save DNS Records of a domain under your account
- Get, Modify or delete the Nameservers of a domain under your account
- Enable or disable the registrar lock of a domain
- Get/Save Email Forwarding
- ID Protection
- Domain Cron Synchronization
In requests, Domains Reseller accepts query parameters and the API response is sent in JSON data format.
Endpoint
https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php
Authentication
The Domain Reseller API uses a custom authentication method with username and token:
Parameter | Description |
---|---|
Username | This is the email address of your client account with us |
Token | Token is an API Key transformed into SHA256 hash using your email address and the current time encoded with base64 |
Getting Your API Key
To obtain your API credentials, follow these steps:
Access Your Reseller Area
Log into your Hostraha client area and navigate to:
Go to Settings Section
In the Reseller Area, click on the Settings tab to access your API credentials.
Copy Your Credentials
You'll find your API details including:
- Username: Your reseller account email address
- API Key: Your unique API key for authentication
- Endpoint URL: The API endpoint for making requests
Token Generation Formula
base64_encode(hash_hmac("sha256", "<api-key>", "<email>:<gmdate("y-m-d H")>"))
Sample Request
Here's a complete example of how to make a request to renew a domain using PHP:
<?php
$endpoint = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php";
$action = "/order/domains/renew";
$params = [
"domain" => "example.com",
"regperiod" => "3",
"addons" => [
"dnsmanagement" => 0,
"emailforwarding" => 1,
"idprotection" => 1,
]
];
$headers = [
"username: [email protected]",
"token: ". base64_encode(hash_hmac("sha256", "1234567890QWERTYUIOPASDFGHJKLZXCVBNM", "[email protected]:".gmdate("y-m-d H")))
];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "{$endpoint}{$action}");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
JavaScript/Node.js Example
const crypto = require('crypto');
// Function to generate token
function generateToken(apiKey, email) {
const currentTime = new Date().toISOString().slice(0, 13).replace(/[-T]/g, '-').replace(':', ' ');
const data = `${email}:${currentTime}`;
const hash = crypto.createHmac('sha256', apiKey).update(data).digest('base64');
return hash;
}
// API request function
async function renewDomain(email, apiKey, domain, regperiod = 1) {
const endpoint = 'https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php';
const action = '/order/domains/renew';
const params = new URLSearchParams({
domain: domain,
regperiod: regperiod.toString(),
'addons[dnsmanagement]': '0',
'addons[emailforwarding]': '1',
'addons[idprotection]': '1'
});
const token = generateToken(apiKey, email);
try {
const response = await fetch(`${endpoint}${action}`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'username': email,
'token': token
},
body: params.toString()
});
const result = await response.json();
return result;
} catch (error) {
console.error('Error renewing domain:', error);
throw error;
}
}
// Usage example
renewDomain('[email protected]', 'YOUR_API_KEY', 'example.com', 3)
.then(result => console.log('Domain renewal result:', result))
.catch(error => console.error('Error:', error));
Python Example
import requests
import hashlib
import hmac
import base64
from datetime import datetime
def generate_token(api_key, email):
"""Generate authentication token for Domain Reseller API"""
current_time = datetime.utcnow().strftime('%y-%m-%d %H')
data = f"{email}:{current_time}"
# Create HMAC-SHA256 hash
signature = hmac.new(
api_key.encode('utf-8'),
data.encode('utf-8'),
hashlib.sha256
).digest()
# Encode to base64
token = base64.b64encode(signature).decode('utf-8')
return token
def renew_domain(email, api_key, domain, regperiod=1):
"""Renew a domain using the Domain Reseller API"""
endpoint = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php"
action = "/order/domains/renew"
# Generate authentication token
token = generate_token(api_key, email)
# Prepare request data
data = {
'domain': domain,
'regperiod': str(regperiod),
'addons[dnsmanagement]': '0',
'addons[emailforwarding]': '1',
'addons[idprotection]': '1'
}
headers = {
'username': email,
'token': token,
'Content-Type': 'application/x-www-form-urlencoded'
}
try:
response = requests.post(f"{endpoint}{action}", data=data, headers=headers)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error renewing domain: {e}")
raise
# Usage example
if __name__ == "__main__":
email = "[email protected]"
api_key = "YOUR_API_KEY"
domain = "example.com"
try:
result = renew_domain(email, api_key, domain, regperiod=3)
print("Domain renewal result:", result)
except Exception as e:
print("Error:", e)
Available API Actions
The Domain Reseller API supports various actions for domain management. Each action is accessed by appending the action path to the base endpoint.
Domain Registration
/order/domains/register
Domain Transfer
/order/domains/transfer
Domain Renewal
/order/domains/renew
/domains/release
/domains/contacts/update
/domains/epp-code
DNS Management
/domains/dns/records
/domains/dns/records
Nameserver Management
/domains/nameservers
/domains/nameservers
/domains/nameservers
Domain Protection & Services
/domains/registrar-lock
/domains/email-forwarding
/domains/email-forwarding
/domains/id-protection
/domains/sync