BacklinkBuilder

Backlink Builder Pro API

Welcome to the Backlink Builder Pro API documentation! This API allows you to programmatically initiate backlink generation campaigns for your websites. Integrate our powerful backlinking capabilities directly into your applications, dashboards, or automated workflows.


1. Authentication

Currently, our API relies on session-based authentication. This means that any API requests made from your web application (e.g., via JavaScript in the browser) will automatically use the active user session.

For server-to-server integrations or more robust external applications, we recommend a more secure method like API Keys. If you require API key access, please contact our support team.

2. API Endpoint

All requests for initiating backlink campaigns should be sent to the following endpoint:

POST /api/process_backlinks.php

3. Request Format

Requests must be sent as POST requests with a Content-Type: application/json header. The request body should be a JSON object containing the following parameters:

Parameter Type Required Description
url string Yes The full URL of the website for which to generate backlinks (e.g., https://example.com).
keywords string No Comma-separated keywords relevant to your URL (e.g., "SEO, digital marketing").
backlinks_requested integer Yes The desired number of backlinks to generate for this campaign.

Example Request Body:

{
    "url": "https://yourwebsite.com/your-page",
    "keywords": "your keywords, separated, by commas",
    "backlinks_requested": 10
}

4. Response Format

The API will respond with a JSON object.

Success Response (HTTP Status: 200 OK)

{
    "success": true,
    "message": "Backlink generation campaign successfully initiated!",
    "campaign_id": 12345,
    "redirect_url": "/dashboard.php?campaign=12345"
}

Error Response (HTTP Status: 400, 401, 402, 500)

{
    "success": false,
    "error": "Error message explaining the issue."
}

Common Error Codes:

5. Code Examples

Here are examples of how to interact with the API using common programming languages.

JavaScript (Browser-side using Fetch API)

This is suitable for web applications where the user is already logged in.

async function initiateBacklinkCampaign(url, keywords, backlinksRequested) {
    try {
        const response = await fetch('/api/process_backlinks.php', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                url: url,
                keywords: keywords,
                backlinks_requested: backlinksRequested
            })
        });

        const data = await response.json();

        if (response.ok && data.success) {
            console.log('Campaign initiated:', data.message);
            console.log('Campaign ID:', data.campaign_id);
            // You might want to start polling for status here, or redirect
            return data; // Return the success data
        } else {
            console.error('API Error:', data.error || 'Unknown error');
            throw new Error(data.error || 'Failed to initiate campaign.');
        }
    } catch (error) {
        console.error('Network or unexpected error:', error);
        throw error; // Re-throw for calling function to handle
    }
}

// Example usage:
// initiateBacklinkCampaign('https://myawesomeblog.com/latest-post', 'blogging, SEO tips', 25)
//     .then(result => {
//         console.log('Campaign started successfully:', result);
//         // Redirect or update UI
//     })
//     .catch(error => {
//         console.error('Failed to start campaign:', error.message);
//         // Display error to user
//     });

PHP (Server-side using cURL)

This example demonstrates how to make an API call from a PHP backend, which is useful for server-to-server integrations or if you're building a custom plugin. Note: For this to work, your PHP environment needs to have curl extension enabled.

<?php

function initiateBacklinkCampaignPHP($url, $keywords, $backlinksRequested) {
    $api_endpoint = 'https://backlink-builder.pro/api/process_backlinks.php'; // Use your actual domain

    $data = [
        'url' => $url,
        'keywords' => $keywords,
        'backlinks_requested' => $backlinksRequested
    ];

    $ch = curl_init($api_endpoint);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        // If using API keys, you'd add an Authorization header here:
        // 'Authorization: Bearer YOUR_API_KEY'
    ]);

    // IMPORTANT: If your API requires session cookies (which it currently does),
    // and you're calling this from a different domain or a cron job,
    // you'll need to handle session cookies or switch to API key authentication.
    // For server-to-server, API keys are strongly recommended.

    $response = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $curl_error = curl_error($ch);
    curl_close($ch);

    if ($response === false) {
        error_log("cURL Error: " . $curl_error);
        return ['success' => false, 'error' => "Network error: " . $curl_error];
    }

    $decoded_response = json_decode($response, true);

    if ($http_code >= 200 && $http_code < 300 && isset($decoded_response['success']) && $decoded_response['success'] === true) {
        return $decoded_response; // Success
    } else {
        $error_message = $decoded_response['error'] ?? 'Unknown API error.';
        error_log("API Call Failed (HTTP $http_code): " . $error_message);
        return ['success' => false, 'error' => $error_message];
    }
}

// Example usage:
// $result = initiateBacklinkCampaignPHP('https://mycustomapp.com/page', 'app development, tech', 50);
// if ($result['success']) {
//     echo "Campaign started successfully! ID: " . $result['campaign_id'];
// } else {
//     echo "Failed to start campaign: " . $result['error'];
// }

?>

6. Rate Limiting and Usage

To ensure fair usage and system stability, API requests may be subject to rate limiting. Excessive requests in a short period might result in temporary blocks. Additionally, your backlink generation requests will consume your plan's allocated quota, as detailed in your subscription.

7. Need Help?

If you have any questions, encounter issues, or require further assistance with integrating the Backlink Builder Pro API, please do not hesitate to contact our support team at support@backlink-builder.pro.