Upload API

0. Get your API key
You can find it on «Settings» page https://turbobit.net/user/settings
Also if you need links for hitfile.net, enable «Automatically upload files to all active services»
and «Automatically create and display links for hitfile.net» options

1. Get upload server details

Send POST request to https://turbobit.net/v001/upload/http/server

Send Params
api_key - Your API key from previous step

Return Params (example)

                
{
    "url": "http://s209.turbobit.net/uploadfile",
        "params": {
            "apptype": "fd1",
            "upload_info": "F+ZuaV6EN1a4cdftUSIX4ZwMCswN9jB58d0/"
        },
    "result": true
}
                
            

2. Upload file
Send POST request to server url (parameter from the previous query result)

Send Params
apptype - Parameter from the previous query result
upload_info - Parameter from the previous query result
folder_id (optional) - If your want upload file to a specific folder
Filedata - Your file

Return Params (example)

                
{
     "result":true,
     "id":"1i555e01nb3",
     "cid":"6dcUDq1",
     "message":"Everything is ok"
}
                
        

id - turbobit.net file id
cid - hitfile.net file id

Full example using PHP

        
reporting(E_ALL);
ini_set('display_errors', '1');


function turbobit_upload($apiKey, $file, $folderId = 0)
{
    // Get upload server
    $ch = curl_init('https://turbobit.net/v001/upload/http/server/');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array('api_key' => $apiKey));
    $postResult = curl_exec($ch);
    curl_close($ch);
    $res = json_decode($postResult);
    if (!$res->result) {
        print $res->message;
        return false;
    }

    // POST variables
    $postParams = array();
    foreach ($res->params as $field => $value) {
        $postParams[$field] = $value;
    }
    $postParams['folder_id'] = intval($folderId);
    if (function_exists('curl_file_create')) { // php 5.5+
        $postParams['Filedata'] = curl_file_create($file);
    } else { //
        $postParams['Filedata'] = '@' . realpath($file);
    }

    // Upload file
    $ch = curl_init($res->url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postParams);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $postResult = curl_exec($ch);
    if (curl_errno($ch)) {
        print curl_error($ch);
        print "Unable to upload file.";
       return false;
    }
    curl_close($ch);
    $res = json_decode($postResult, true);
    if (!($res['result'])) {
        print "Upload error:" . $res['message'];
        return false;
    }

    // Make file links from IDs
    $links = array();
    $links['turbobit'] = "https://turbobit.net/{$res['id']}.html";
    if (isset($res['cid'])) {
        $links['hitfiles'] = "https://hitfile.net/{$res['cid']}";
    }
    return $links;
}

$apiKey = 'YOUR_KEY';
// from https://turbobit.net/user/settings
$links = turbobit_upload($apiKey, '/home/user/tmp/file.zip', 0);
print_r($links);
/*

 Array
(
    [turbobit] => https://turbobit.net/1i555e01nb3.html
    [hitfiles] => https://hitfile.net/6dcUDq1
)
 */