API Documentation

Learn how to integrate domain and hosting provider APIs with TurboHostPro

Introduction

TurboHostPro allows you to integrate with multiple domain and hosting providers through their APIs. This documentation will guide you through the process of setting up these integrations, authenticating with the providers, and performing common operations.

Authentication

TurboHostPro uses a secure vault to store your API credentials. Your credentials are encrypted and never exposed to end users. You'll need to provide your API keys in the TurboHostPro admin panel under Settings > API Integrations.

Authentication Methods
Different providers use different authentication methods

API Key + Secret

Used by ResellerClub, Namecheap

OAuth 2.0

Used by GoDaddy, some cPanel instances

Username + Password

Used by some WHM/cPanel instances

Token-based

Used by Plesk, DirectAdmin

API Keys

To obtain API keys from your providers, follow these general steps:

  1. Log in to your provider's control panel or account dashboard
  2. Navigate to API settings, developer tools, or integrations section
  3. Generate a new API key or create API credentials
  4. Set appropriate permissions and access levels
  5. Copy the API key and secret to your TurboHostPro admin panel

Domain Provider Integration

ResellerClub API Integration

Recommended

ResellerClub offers a comprehensive reseller platform for domains and hosting. Their API allows you to perform domain registrations, transfers, renewals, and DNS management.

Step 1: Obtain API Credentials
  1. Log in to your ResellerClub reseller account
  2. Navigate to Settings > API
  3. Generate a new API key if you don't have one
  4. Note your ResellerID and API Key
Step 2: Configure in TurboHostPro
  1. Go to your TurboHostPro admin panel
  2. Navigate to Settings > API Integrations
  3. Click "Add New Provider" and select "ResellerClub"
  4. Enter your ResellerID and API Key
  5. Select environment (Testing or Production)
  6. Click "Test Connection" to verify
  7. Save your configuration
Step 3: API Configuration
{
  "provider": "resellerclub",
  "credentials": {
    "resellerId": "YOUR_RESELLER_ID",
    "apiKey": "YOUR_API_KEY"
  },
  "environment": "production",
  "settings": {
    "defaultNameServers": [
      "ns1.yourdomain.com",
      "ns2.yourdomain.com"
    ],
    "defaultContactId": "12345678",
    "autoRenew": true
  }
}
json
Example: Domain Availability Check
// Server-side code (Next.js API route)
import { checkDomainAvailability } from '@/lib/providers/resellerclub';

export async function POST(req) {
  const { domain, tlds } = await req.json();
  
  try {
    const results = await checkDomainAvailability(domain, tlds);
    return Response.json({ success: true, results });
  } catch (error) {
    console.error('Error checking domain availability:', error);
    return Response.json({ success: false, error: error.message }, { status: 500 });
  }
}
javascript

Hosting Provider Integration

SiteGround API Integration

Popular Choice

SiteGround offers a comprehensive hosting platform with AI-driven optimizations and world-class performance. Their API allows you to manage hosting accounts, WordPress installations, and website deployments.

Step 1: Obtain API Credentials
  1. Log in to your SiteGround reseller account
  2. Navigate to Tools & Settings > API
  3. Generate a new API token with appropriate permissions
  4. Note your API endpoint URL and token
Step 2: Configure in TurboHostPro
  1. Go to your TurboHostPro admin panel
  2. Navigate to Settings > API Integrations
  3. Click "Add New Provider" and select "SiteGround"
  4. Enter your API endpoint URL and token
  5. Select environment (Staging or Production)
  6. Click "Test Connection" to verify
  7. Save your configuration
Step 3: API Configuration
{
  "provider": "siteground",
  "credentials": {
    "apiEndpoint": "https://api.siteground.com/v1",
    "apiToken": "YOUR_API_TOKEN"
  },
  "environment": "production",
  "settings": {
    "defaultDataCenter": "us-east",
    "defaultPHPVersion": "8.1",
    "autoSSL": true,
    "backupRetention": 30
  }
}
json
Example: Create Hosting Account
// Server-side code (Next.js API route)
import { createSiteGroundAccount } from '@/lib/providers/siteground';

export async function POST(req) {
  const { domain, plan, customerEmail, phpVersion } = await req.json();
  
  try {
    const result = await createSiteGroundAccount({
      domain,
      plan,
      customerEmail,
      phpVersion: phpVersion || '8.1',
      features: {
        ssl: true,
        backup: true,
        staging: true
      }
    });
    
    return Response.json({ 
      success: true, 
      accountId: result.accountId,
      loginUrl: result.loginUrl,
      credentials: result.credentials
    });
  } catch (error) {
    console.error('Error creating SiteGround account:', error);
    return Response.json({ 
      success: false, 
      error: error.message 
    }, { status: 500 });
  }
}
javascript
SiteGround Features

Performance Features

  • • 99.9% uptime guarantee
  • • AI-powered optimizations
  • • Global CDN included
  • • SSD storage

Management Features

  • • One-click WordPress install
  • • Free SSL certificates
  • • Daily backups
  • • Staging environments

API Reference

TurboHostPro provides a unified API that abstracts away the differences between providers. This allows you to use a consistent interface regardless of which providers you've integrated.

Domain API
Methods for domain management

checkAvailability(domain, tlds)

Check domain availability across multiple TLDs

registerDomain(domain, years, contactInfo)

Register a new domain

transferDomain(domain, authCode, years, contactInfo)

Transfer a domain from another registrar

renewDomain(domain, years)

Renew an existing domain

updateNameservers(domain, nameservers)

Update domain nameservers

Hosting API
Methods for hosting account management

createAccount(options)

Create a new hosting account

suspendAccount(username, reason)

Suspend a hosting account

unsuspendAccount(username)

Unsuspend a hosting account

changePackage(username, newPackage)

Change a hosting account's package

Webhooks

TurboHostPro supports webhooks to notify your application of important events such as domain registrations, renewals, and hosting account changes.

Setting Up Webhooks
  1. Go to your TurboHostPro admin panel
  2. Navigate to Settings > Webhooks
  3. Click "Add Webhook Endpoint"
  4. Enter your endpoint URL
  5. Select the events you want to receive notifications for
  6. Generate a webhook secret for signature verification
  7. Save your configuration

Example Webhook Payload

{
  "event": "domain.registered",
  "timestamp": "2023-06-08T12:34:56Z",
  "data": {
    "domain": "example.com",
    "registrationDate": "2023-06-08T12:34:56Z",
    "expiryDate": "2024-06-08T12:34:56Z",
    "registrantEmail": "customer@example.com",
    "provider": "resellerclub"
  }
}
json

Verifying Webhook Signatures

// Server-side code (Next.js API route)
import { createHmac } from 'crypto';

export async function POST(req) {
  const payload = await req.json();
  const signature = req.headers.get('x-turbohostpro-signature');
  const webhookSecret = process.env.WEBHOOK_SECRET;
  
  // Verify signature
  const expectedSignature = createHmac('sha256', webhookSecret)
    .update(JSON.stringify(payload))
    .digest('hex');
    
  if (signature !== expectedSignature) {
    return Response.json({ error: 'Invalid signature' }, { status: 401 });
  }
  
  // Process the webhook
  const { event, data } = payload;
  
  // Handle different event types
  switch (event) {
    case 'domain.registered':
      // Handle domain registration
      break;
    case 'hosting.created':
      // Handle hosting account creation
      break;
    // ...other events
  }
  
  return Response.json({ success: true });
}
javascript

Troubleshooting

Common issues and solutions when integrating with domain and hosting provider APIs.

API Connection Failures
  • Verify your API credentials are correct
  • Check if your IP is whitelisted (for providers that require it)
  • Ensure your server can reach the provider's API endpoints
  • Check for SSL/TLS issues if using HTTPS
  • Verify you're using the correct API environment (test vs. production)
Rate Limiting

Most providers implement rate limiting to prevent abuse. If you're making too many requests in a short period, you may be temporarily blocked.

  • Implement exponential backoff for retries
  • Cache responses when appropriate
  • Batch operations when possible
  • Monitor your API usage
Debugging Tools

TurboHostPro provides several tools to help you debug API integrations:

  • API Logs: View detailed logs of all API requests and responses
  • Test Mode: Test API integrations without making actual changes
  • API Explorer: Interactive tool to make API calls directly