People that are interested in using our service for automated caching of their newly created .torrent files or caching massive amounts of older files, can do so by using one our APIs.
This page contains some documentation on the APIs but also some example code in different 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 cached at http://itorrents.org/torrent/<infoHash>.torrent

Note: HEX values A-F must be in uppercase in torrent URL's


The SOAP API is probably the most easy to use in a modern scripting/programming language. The WSDL offers one simply function; cacheTorrent(). The function returns the info hash of the torrent on success, or a three digit error code if there was an error.
The SOAP WSDL is located at http://itorrents.org/api/torrage.wsdl.


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

        $client = new SoapClient( 'http://itorrents.org/api/torrage.wsdl' );
        $infoHash = $client->cacheTorrent( base64_encode( file_get_contents( 'my.torrent' ) ) );


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


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://itorrents.org/api/torrage.wsdl' )->cacheTorrent( $tor );

print $infoHash;


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.


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

    $files = 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://itorrents.org/autoupload.php', array(), $files );
    $tmp = explode( "\r\n", $http_resp );
    $infoHash = substr( $tmp[count( $tmp ) - 1], 0, 40 );
    unset( $tmp, $http_resp, $files );