# Streamload API

This is a short desciption of the Streamload server protocol. I created this page while programming the Net::Streamload module for Perl. This is not the official protocol description, refer to the Streamload Developer Page for that.

This protocol works with the Streamload upload servers at upload.streamload.com, ports 9914 and 80 (for firewalls).

I'm using the following abbreviations and colors to mark the different data types used by Streamload:

symbol | type | length | special
--- | --- | --- | ---
b | boolean | 8-bit | non-zero implies truth
i | integer | 32-bit | signed
l | quad integer | 64-bit | signed
s | string | 32-bit + length of string | see notes
d | data | different | plain binary dump

Some notes:

- A string consists of its length (i) and the string itself, which is transfered as single byte characters
- All numbers are transfered Intel byte-ordered / little-endian.
- The Version of this API is 1.2, so version major is 1 and version minor is 2.

The structure of the following tables is this:

Client | Server
--- | ---

### Login (command id 0):

command id (i)
version major (i)
version minor (i)
username (s)
password (s) (can be blank FORNOW)
| success (b)
| true | false
| Node ID "My Stuff" (l) | Error Message (s) - END
| Node ID "My Stuff" (l)
| Node ID "Playlists" (l)
| Node ID "Inbox" (l)
| Success

### EnsureFolder (command id 1):

command id (i)
folder name (s)
parent folder Node ID (l)
whether to use the same-named folder (b)
| success (b)
| true | false
| new folder Node ID (l) | Error Message (s) - END
| Success

### UploadInit (command id 2):

command id (i)
parent folder Node ID (l)
media ID (s)
local path (s)
length of file (l)
whether to replace/update the same-named file (b)
| success (b)
| true: UpStreamload | false: Upload

### UpStreamload:

| key size (i)
| key count (i)
| Repeat
| key index n (l)
| until (n++ == key count)
buffer of key values (d)
| success (b)
| true | false
| repeat | Error Message (s) - END
| processing progress percentage (i)
| until (processing progess == 0)
| success (b)
| true | false
| new node ID (l) | Error Message (s) - END
| Success

### Upload:

bytes of file (d)
| success (b)
| true | false
| repeat | Error Message (s) - END
| processing progress percentage (i)
| until (processing progess == 0)
| success (b)
| true | false
| bogus value (l) | Error Message (s) - END
| Success

bogus value: This has been the new node ID, but lost its meaning after the update to Streamload v2.

### URLStreamload (command id 3):

WARNING: This feature is currently disabled in the Steamload servers and will probably not be reenabled any time soon.

command id (i)
parent folder Node ID (l)
URL to load from (s)
whether to replace/update the same-named file (b)
| success (b)
| true | false
| file size (l) | Error Message (s) - END
| repeat
| success (b)
| true | false
| download progress (l) | Error Message (s) - END
| until (download progess == 0)
| repeat
| success (b)
| true | false
| processing progress percentage (i) | Error Message (s) - END
| until (processing progess == 0)
| success (b)
| true | false
| new node ID (l) | Error Message (s) - END
| Success