Tuyu Developers

Developers

Customize the URLs on this site with your Tuyu URL:

https:// .

User Authentication

To use the API you will first need an API Key and API Secret. Most requests require a signature in order to validate the request.

Signing GET Requests

  1. Sort your parameters alphabetically by name. For example, if you are trying to retrieve a list of files in a particular location and use the following parameters:

    • path: “%2F” (the url-encoded version of "/")
    • sort_by: “date_asc”
    • api_key: “key”

    You would form your URL as such:

    https://<your subdomain>.<your domain>/api/file_list?api_key=key&path=%2F&sort_by=date_asc&timestamp=<current time>
  2. Using the URL, create a signature using HMAC-SHA256, using the SHA1 hash of your API secret as the key. An example in PHP would look like this:

    $signature = hash_hmac(‘sha256’, <URL from above>, sha1(<your API secret>));
  3. Add this signature as a parameter to the end of your URL like this:

    https://<your subdomain>.<your domain>/api/file_list?api_key=key&path=%2F&sort_by=date_asc&timestamp=<current time>&signature=<signature>

Signing POST/PUT/DELETE Requests

  1. Simply pass the URL of the API method into your HMAC-SHA256 signature creator. An example in PHP:

    $signature = hash_hmac(‘sha256’, ‘https://<your subdomain>.<your domain>/api/file_upload’, sha1(<your API secret>));
  2. Pass the signature as a parameter in your POST/PUT/DELETE body along with your other parameters.