SendBit API Example




SendBit API Example

This example demonstrates how to use the SendBit API in your PHP application.

Generate Address

Generate a new address associated with the provided API key.

        
// Generate Address cURL request
$generateAddressData = [
'api_key' => 'your_api_key',
'mainChain' => 'ETH',
'callback_url' => 'https://callbackurl.com',
];


// Function to make a cURL request
    function makeCurlRequest($url, $data) {
        $ch = curl_init($url);

        // Set cURL options
        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']);

        // Execute cURL session and get the response
        $response = curl_exec($ch);

        // Check for cURL errors
        if ($response === false) {
            echo 'cURL error: ' . curl_error($ch);
        }

        // Close cURL session
        curl_close($ch);

        return $response;
    }



$generateAddressResponse = makeCurlRequest('https://sendbit.io/api.php', $generateAddressData);

echo "Generate Address Response: " . $generateAddressResponse . PHP_EOL;