BAYFILES API
============

The API is currently in BETA mode. It can still change until we gathered enough feedback to freeze it.

Base URL: http://api.bayfiles.com/v1/

All responses return a JSON object with at least one property called "error".
In case the API call failed, "error" will be populated with the error message.
Otherwise it is set to an empty string to indicate success.

If you want to execute any API calls as a logged in user, then you need to first
issue a call to /account/login which will return a session ID. Append this session ID
to all calls as a querystring (?session=<sessionId>). Should the session expire,
all API calls will return "session expired" as error and you'll have to re-login.

* <string>	means a UTF-8 encoded string
* <int>		means a 64 bit unsigned integer
* <bool>	means a boolean value represented either as 0 or 1

Dates are always UTC

Changelog
---------

v1.0 2011/09/03
* initial release


File Actions
------------

/file/uploadUrl

{ error: "", uploadUrl: <string>, progressUrl: <string> }

The returned URL is valid for a limited amount of time, you need to request a new one for each upload.
Issue a POST request to the "uploadUrl" to upload the file. You can poll "progressUrl" to fetch the current progress.
The POST request needs to be multipart/form-data encoded and contain a "file" field.
cUrl example: curl -F "file=@somefile.rar" "http://s6.baycdn.com/upload/93b37e57/4e691e0c/6/0?X-Progress-ID=4e639fcd34CC2F73796CF81679C605643A8F99CF"
Note: in order to upload a file to your account, you need to first log in using /account/login and then append ?session=XYZ to /file/uploadUrl
On success, the "uploadUrl" will respond with an object:
{ error: "", fileId: <string>, size: <int>, sha1: <string>, infoToken: <string>, deleteToken: <string>, linksUrl: <string>, downloadUrl: <string>, deleteUrl: <string>, }



/file/info/<fileId>/<infoToken>[/<fileId2>/<infoToken2>]

{ error: "", <fileId>: { size: <int>, sha1: <string>, name: <string> } }

Should a file not be available, then it will be omitted from the returned JSON object.



/file/delete/<fileId>/<deleteToken>

{ error: "" }



Account Actions
---------------

/account/login/<username>/<password>

{ error: "", session: <string> }



/account/logout

{ error: "" }



/account/info

{ error: "", username: <string>, email: <string>, files: <int>, storage: <int>, premium: <bool>, expires: <int>, codes: <int> }

"expires" is a unix timestamp, specifies when the premium account will expire



/account/edit/<key>/<value>

{ error: "", username: <string>, email: <string>, files: <int>, storage: <int>, premium: <bool>, expires: <int>, codes: <int> }

<key> is a <string> containing one of the following values: "password", "email".
<value> is the new value that <key> should be changed to.



/account/files

{ error: "", <fileId>: { infoToken: <string>, deleteToken: <string>, size: <int>, sha1: <string>, filename: <string> } }

For each file in the account, a seperate <fileId> property is added to the result object.
Forgot your password?

3-18 characters. Characters allowed: A-Z, 0-9, _, ., and -

Your password has to be at least 6 characters long.

A valid email is needed to reset your password in case you lose it.