People that are interested in using our service for automated storing of their newly created .torrent files or storing massive amounts of older files, can do so by using one of our APIs.
This page contains some documentation on the APIs but also some example code in different programming languages. If you have some code for any additional language we do not cover, please give us some working example code over e-mail.
All files will be stored at http://TheTorrent.org/<INFO_HASH>.torrent

SOAP API

The SOAP API is probably the most easy to use in a modern scripting/programming language. The WSDL offers one simply function - storeTorrent(). The function returns the info hash of the torrent on success, or an error message if there was an error. The SOAP WSDL is located at http://TheTorrent.org/api/thetorrent.wsdl

PHP

Below is example code in PHP to store "my.torrent". You would need to compile PHP with --enable-soap option.

<?php
    $client = new SoapClient( 'http://thetorrent.org/api/thetorrent.wsdl' );
    $infoHash = $client -> storeTorrent( base64_encode( file_get_contents( 'my.torrent' ) ) );
?>

PERL

Perl code to store "my.torrent". Requires SOAP::Lite (libsoap-lite-perl in debian)

#!/usr/bin/perl

use MIME::Base64 ();
use SOAP::Lite ();

open( FILE, 'my.torrent' ) or die "$!";
while( read( FILE, $buf, 60*57 ) ) { $tor .= MIME::Base64::encode( $buf ); }
close( FILE );

$infoHash = SOAP::Lite->service( 'http://thetorrent.org/api/thetorrent.wsdl' )->storeTorrent( $tor );

print $infoHash;

HTTP POST

If you don't have support for SOAP there is a normal HTTP POST interface. Here we show some example code for that as well.

PHP

Below is example code to store "my.torrent". This feature requires the pecl_http extension.

<?php
    $files = array(
        array(
            'name' => 'torrent',			// Don't change
            'type' => 'application/x-bittorrent',
            'file' => 'my.torrent'			// Full path for file to upload
        )
    );

    $http_resp = http_post_fields( 'http://thetorrent.org/autoupload.php', array(), $files );
    $headers   = http_parse_headers ( $http_resp );             
                                                                
    if ( $headers["X-Thetorrent-Result"] == "stored" )
    {
        $infoHash = $headers["X-Thetorrent-Hash"];
        echo $infoHash;
    }
     elseif ( $headers["X-Thetorrent-Result"] == "failed" )
    {
        $error =  $headers["X-Thetorrent-Error"];
        echo $error;
    }
    unset( $headers, $http_resp, $files, $error );
?>

Info

There are 43868385 stored torrents.