Downloads: Download File

Upon queuing a track for download, a user will receive a download token that is needed in order to request the file from any POOL media server. This API call requires a series of authentications to take place in order to succeed. Four components are required: the track must be a part of the user's POOL distribution, a valid server host address is needed from the Available Download Servers call, the user must have a valid download token, the user needs a valid access token.

Download File Specification

Parameters: Header variables:
  1. userid: integer
  2. token: string

Download File Workflow

  1. Get DOWNLOAD_TOKEN from Queue Download
  2. Get SERVER_HOST_LOCATION from Queue Download or Available Servers
  3. URL: http://SERVER_HOST_LOCATION/pool/v5/download/DOWNLOAD_TOKEN
  4. Header: Authorization: Bearer Base64(userid:token)
  5. Method: GET
  6. Returned: Media file

Examples

  1. PHP (using cURL):

    <?php
        $userid = 1;
        $token = "8b26e1e4f3f5e00a888807e605565c47";

        $trackid = 373748;
        $queue_download_url = "https://api.promoonly.com/download/queue/".$trackid;

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $query_download_url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ".base64_encode($userid.":".$token)));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $queue_result = curl_exec($ch);
        curl_close($ch);
        $queue_obj = json_decode($queue_result);

        $dl_token = trim($queue_obj->dl_token);
        $host_server = trim($queue_obj->servers[0]);
        $download_url = "http://".$host_server."/pool/v5/download/".$dl_token;

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $download_url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ".base64_encode($userid.":".$token)));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $media_file_content = curl_exec($ch);
        curl_close($ch);
    ?>
  2. Python (using requests):

    #!/usr/bin/env python

    import requests
    import base64
    import urllib
    import json

    userid = 1
    token = "8b26e1e4f3f5e00a888807e605565c47"

    trackid = 373748
    queue_download_url = "https://api.promoonly.com/download/queue/%s" % trackid

    b64_key = base64.b64encode("%s:%s" % (userid, token))
    headers = {"Authorization": "Bearer %s" % b64_key}

    queue_result = json.loads(requests.get(queue_download_url, headers=headers))
    dl_token = queue_result["dl_token"]
    host_server = queue_result["servers"][0]

    download_url = "http://%s/pool/v5/download/%s" % (host_server, dl_token)
    media_file_content = requests.get(download_url, headers=headers)