NAV
php shell

Tokenly Music API

Welcome to the Tokenly Music API.

You can use the public API to register and login users and retrieve album and song listings.

The protected API retrieves song download information if authorized for the user.

All API calls begin with https://music.tokenly.com.

The PHP examples in use the PHP SDK which can be found at https://github.com/tokenly/music-api-client.

Authentication

Protected API calls require authentication. See https://github.com/tokenly/hmac-auth/blob/master/README.md for details.

Public API Methods

Get All Albums

<?php
$albums = $music_api->getAlbums();
curl -X GET https://music.tokenly.com/api/v1/music/catalog/albums

The above command returns data structured like this:

[
  {
    "id": "cc6f8915-a7b3-4da1-aa5f-7e505291a181",
    "name": "A Little Color EP",
    "description": "Released on January 10th, 2016 - A Little Color EP is Adam B. Levine's first release of original music under the name "Mind To Matter" and on the website mindtomatter.org. ",
    "songCount": 5,
    "artworkImage": "https://music.tokenly.com/path/to/image.png",
    "artistProfileID": "54fbbba5-7d7b-4fa6-bb91-000000000002"
  }
]

Lists all available publicly available albums.

HTTP Request

GET https://music.tokenly.com/api/v1/music/catalog/albums

Get Songs for an Album

<?php
$songs = $music_api->getSongs('cc6f8915-a7b3-4da1-aa5f-7e505291a181');
curl -X GET https://music.tokenly.com/api/v1/music/catalog/songs/cc6f8915-a7b3-4da1-aa5f-7e505291a181

The above command returns data structured like this:

[
  {
    "id": "c795531a-23e7-4dd5-aa29-4b670d45158c",
    "name": "Ears on the Ground",
    "tokens": [
      "LITTLECOLOR",
      "MTMYEARONE",
      "MTMCOLLECTOR",
      "MTMPRODUCER"
    ],
    "description": "",
    "performers": "Mind To Matter",
    "composers": "Adam B. Levine",
    "releaseDate": "2016-03-26T20:31:12+0000",
    "lyrics": "",
    "credits": "",
    "copyright": "Adam B. Levine 2016",
    "ownership": "Adam B. Levine",
    "usageRights": "",
    "usageProhbitions": "",
    "bitcoinAddress": "1GJchZwagFFxXMUnRyQFVDe8QSKb9mJKXS",
    "other": ""
  }
]

Returns a list of songs for a given album.

HTTP Request

GET https://music.tokenly.com/api/v1/music/catalog/songs/{albumid}

URL Parameters

Parameter Description
albumid The album identifier

Load a User Profile

<?php
$songs = $music_api->findProfile('musiclover123');
curl -X GET https://music.tokenly.com/api/v1/profiles/musiclover123

The above command returns data structured like this:

{
    "bio": "I luv music."
}

Returns the public profile information for a user by username

HTTP Request

GET https://music.tokenly.com/api/v1/profiles/{username}

URL Parameters

Parameter Description
username The username to find

Search the Music Library

<?php
$songs = $music_api->searchLibrary(['artist' => 'Mr. Chips']);
curl -X GET https://music.tokenly.com/api/v1/library?artist=Mr.%20Chips

The above command returns data structured like this:

{
    "page": 0,
    "perPage": 50,
    "pageCount": 1,
    "count": 2,
    "items": [
        {
            "id": "bbb51108-9e89-4863-8b90-000000000001",
            "name": "Song 1",
            "tags": "bitcoin, rock, techno",
            "tagsArray": ["bitcoin", "rock", "techno"],
            "genre": "Alternative",
            "releaseDate": "2016-03-26T20:31:12+0000",
            "artist": "Mr. Chips",
            "artistProfileId": "32c999ec-2cd4-427f-b60c-000000000001",
            "description": "Description of song 1",
            "isTokenlyMusic": true,
            "publicStreamable": true,
            "tokens": ["MRCHIPSALBUM"],
            "albumName": "The Album",
            "albumId": "5f3e69c3-7e6a-4758-9dc2-40a0295afa46",
            "artworkImage": "https://music.tokenly.com/path/to/image.png",
            "isSingle": false
        },
        {
            "id": "740e4e3e-438e-45be-b98d-000000000002",
            "name": "Another Song",
            "tags": "bitcoin, rock, techno",
            "tagsArray": ["bitcoin", "rock", "techno"],
            "genre": "Alternative",
            "releaseDate": null,
            "artist": "Other Artist",
            "artistProfileId": null,
            "description": "Description of other song",
            "isTokenlyMusic": false,
            "publicStreamable": true,
            "tokens": [],
            "albumName": "The Album",
            "albumId": "5918b2f6-ee00-4d89-89d8-88ffe19331df",
            "artworkImage": null,
            "isSingle": true
        }
    ]
}

Returns a list of search results

HTTP Request

GET https://music.tokenly.com/api/v1/library

Query Parameters

Parameter Description
name Album name to find. This search uses a keyword search.
artist Artist name to find. This search uses a keyword search.
genre Genre to find
tag Tag to find
token Token to find (must be a valid token name like MYTOKEN or A1234567890)
operator ‘OR’ or 'AND’ search. Defaults to OR.
limit Limit the number of results returned per page (optional, defaults to 50, maximum is 50)
pg current page offset (starting with 0)
<?php
$songs = $music_api->getArtists();
curl -X GET https://music.tokenly.com/api/v1/artists

The above command returns data structured like this:

{
    "count": 2,
    "items": [
        {
            "artist": "Mr. Chips",
            "artistProfileId": "31444a77-4267-43bb-8e45-000000000001",
            "pictureUrl": "https://music.tokenly.com/path/to/pic.jpg",
            "website": "http://mrchipssite.com",
            "genre": "AI Rock",
            "tags": ["ai","rock","techno"]
        },
        {
            "artist": "The Blue Whiles",
            "artistProfileId": null,
            "pictureUrl": "",
            "website": "",
            "genre": "",
            "tags": []
        }
    ],
    "page": 0,
    "pageCount": 1,
    "perPage": 50
}

Returns a list of all featured artists

HTTP Request

GET https://music.tokenly.com/api/v1/artists

Query Parameters

Parameter Description
limit Limit the number of results returned per page (optional, defaults to 50, maximum is 50)
pg current page offset (starting with 0)

Get Genres

<?php
$songs = $music_api->getGenres();
curl -X GET https://music.tokenly.com/api/v1/genres

The above command returns data structured like this:

{
    "count": 2,
    "items": [
        {
            "genre": "Rock and roll",
            "songCount": 510
        },
        {
            "genre": "Bitcoin rap",
            "songCount": 23
        }
    ],
    "page": 0,
    "pageCount": 1,
    "perPage": 50
}

Returns a list of all genres

HTTP Request

GET https://music.tokenly.com/api/v1/genres

Query Parameters

Parameter Description
limit Limit the number of results returned per page (optional, defaults to 50, maximum is 50)
pg current page offset (starting with 0)

Get Tags

<?php
$songs = $music_api->getTags();
curl -X GET https://music.tokenly.com/api/v1/tags

The above command returns data structured like this:

{
    "count": 2,
    "items": [
        {
            "tag": "instrumental",
            "songCount": 250
        },
        {
            "tag": "FLAC",
            "songCount": 50
        }
    ],
    "page": 0,
    "pageCount": 1,
    "perPage": 50
}

Returns a list of all tags

HTTP Request

GET https://music.tokenly.com/api/v1/tags

Query Parameters

Parameter Description
limit Limit the number of results returned per page (optional, defaults to 50, maximum is 50)
pg current page offset (starting with 0)

Load an Artist Profile

<?php
$songs = $music_api->getArtistProfile('musiclover123');
curl -X GET https://music.tokenly.com/api/v1/artist/profile/7252c3bf-a672-4cec-80d3-9455d42e66ab

The above command returns data structured like this:

{
    "name": "Sample Artist Profile",
    "website": "http://mysite.foo",
    "bio": "This is a sample profile with __markdown__.",
    "active": true,
    "genre": "Bitcoin Rock",
    "tags": "bitcoin, rock, techno",
    "tagsArray": ["bitcoin", "rock", "techno"],
    "marketsCatalog": "joe/joes-shop",
    "marketsCatalogUrl": "https://tokenmarkets.com/catalog/joe/joes-shop"
}

Returns the public profile information for an artist by id

HTTP Request

GET https://music.tokenly.com/api/v1/artist/profile/{uuid}

URL Parameters

Parameter Description
uuid The uuid of the artist profile

Get Songs by Artist

<?php
$songs = $music_api->getSongsByArtistProfile('32c999ec-2cd4-427f-b60c-000000000001');
curl -X GET https://music.tokenly.com/api/v1/artist/32c999ec-2cd4-427f-b60c-000000000001/songs

The above command returns data structured like this:

{
    "page": 0,
    "perPage": 50,
    "pageCount": 1,
    "count": 2,
    "items": [
        {
            "id": "bbb51108-9e89-4863-8b90-000000000001",
            "name": "Song 1",
            "tags": "bitcoin, rock, techno",
            "tagsArray": ["bitcoin", "rock", "techno"],
            "genre": "Alternative",
            "releaseDate": "2016-03-26T20:31:12+0000",
            "artist": "Mr. Chips",
            "artistProfileId": "32c999ec-2cd4-427f-b60c-000000000001",
            "description": "Description of song 1",
            "isTokenlyMusic": true,
            "publicStreamable": true,
            "tokens": ["MRCHIPSALBUM"],
            "albumName": "The Album",
            "albumId": "5918b2f6-ee00-4d89-89d8-88ffe19331df",
            "artworkImage": null,
            "isSingle": true
        },
        {
            "id": "740e4e3e-438e-45be-b98d-000000000002",
            "name": "Song Two Preview",
            "tags": "bitcoin, rock, techno",
            "tagsArray": ["bitcoin", "rock", "techno"],
            "genre": "Alternative",
            "releaseDate": null,
            "artist": "Mr. Chips",
            "artistProfileId": "32c999ec-2cd4-427f-b60c-000000000001",
            "description": "Description of other song",
            "isTokenlyMusic": true,
            "publicStreamable": false,
            "tokens": ["MRCHIPSFANS"],
            "albumName": "The Other Album",
            "albumId": "14101af1-f692-4651-87a9-4a228aa4a031",
            "artworkImage": null,
            "isSingle": true
        }
    ]
}

Returns a list of songs for a given artist profile.

HTTP Request

GET https://music.tokenly.com/api/v1/artist/{profileId}/songs

URL Parameters

Parameter Description
profileId The artist profile identifier

Get Album by Id

<?php
$songs = $music_api->getAlbumById('79ace09e-07cc-4f4e-a25f-000000000001');
curl -X GET https://music.tokenly.com/api/v1/music/album/79ace09e-07cc-4f4e-a25f-000000000001

The above command returns data structured like this:

  {
    "id": "79ace09e-07cc-4f4e-a25f-000000000001",
    "name": "A Little Color EP",
    "description": "Released on January 10th, 2016 - A Little Color EP is Adam B. Levine's first release of original music under the name "Mind To Matter" and on the website mindtomatter.org. ",
    "songCount": 5,
    "artworkImage": "https://music.tokenly.com/path/to/image.png",
    "artistProfileID": "54fbbba5-7d7b-4fa6-bb91-000000000002"
  }

Returns a list of songs for a given album.

HTTP Request

GET https://music.tokenly.com/api/v1/music/album/{albumId}

URL Parameters

Parameter Description
albumid The album identifier

Send Password Reset Email

<?php
$email = "user@test.com";
$profile = $music_api->sendPasswordResetEmail($email);
curl -X POST -H "Content-Type: application/json" https://music.tokenly.com/api/v1/password/reset-email \
    -d '{"email": "user@test.com"}'

The above command returns data structured like this:

{
    "success": true
}

Sends an email to reset the user’s password via email.

HTTP Request

POST https://music.tokenly.com/api/v1/password/reset-email

Body Parameters

Parameter Description
email The email address of the user to reset

Reset Password

<?php
$email = "user@test.com";
$token = "ABCD23";
$new_password = "S3creTpA55w0rd!!";
$profile = $music_api->resetPassword($email, $token, $new_password);
curl -X POST -H "Content-Type: application/json" https://music.tokenly.com/api/v1/password/reset \
    -d '{"email": "user@test.com", "token": "ABCD23", "password": "S3creTpA55w0rd!!"}'

The above command returns data structured like this:

{
    "success": true
}

Resets the user’s password.

HTTP Request

POST https://music.tokenly.com/api/v1/password/reset

Body Parameters

Parameter Description
email The email address of the user to reset the password
token The reset token assigned to the user
password The new password

Public Account API Methods

Register

<?php
$username = 'leroyjenkins';
$password = 'ASecretP4$$w0RD';
$email = 'leroyjenkins@test.com';
$invite_code = 'I9XDJ1';
$user_data = $music_api->registerAccount($username, $password, $email, $invite_code);
NEW_USERNAME='leroyjenkins'
NEW_PASSWORD='ASecretP4$$w0RD'
NEW_EMAIL='leroyjenkins@test.com'
INVITE_CODE='I9XDJ1'

curl -H "Content-Type: application/json" -X POST \
  -d '{"username":"'$NEW_USERNAME'","password":"'$NEW_PASSWORD'","email":"'$NEW_EMAIL'","code":"'$INVITE_CODE'"}' \
  https://music.tokenly.com/api/v1/account/register 

The above command returns data structured like this:

{
    "id": "7a000000-8000-a000-b000-cc0000000000",
    "username": "leroyjenkins",
    "email": "leroyjenkins@test.com",
    "apiSecretKey": "Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "apiToken": "Txxxxxxxxxxxxxxx"
}

Registers a new username and password.

This username must not exist in Tokenly Music or Tokenpass. If the user already exists in Tokenpass, use the login method instead.

HTTP Request

POST https://music.tokenly.com/api/v1/account/register

POST Parameters

Parameter Description
username The new username
password The new password
email The new email address
code The invitation code

Login

<?php
$username = 'leroyjenkins';
$password = 'ASecretP4$$w0RD';
$user_data = $music_api->login($username, $password);
EXISTING_USERNAME='leroyjenkins'
EXISTING_PASSWORD='ASecretP4$$w0RD'

curl -H "Content-Type: application/json" -X POST \
  -d '{"username":"'$EXISTING_USERNAME'","password":"'$EXISTING_PASSWORD'"}' \
  https://music.tokenly.com/api/v1/account/login 

The above command returns data structured like this:

{
    "id": "7a000000-8000-a000-b000-cc0000000000",
    "username": "leroyjenkins",
    "email": "leroyjenkins@test.com",
    "apiSecretKey": "Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "apiToken": "Txxxxxxxxxxxxxxx"
}

Get a user’s API credentials with a username and password.

This muser must exist in Tokenly Music or TokenPass. If the user with these credentials exists in TokenPass but not in Tokenly Music, then Tokenly Music will create a new account based on the TokenPass account.

HTTP Request

POST https://music.tokenly.com/api/v1/account/login

POST Parameters

Parameter Description
username The existing username
password The existing password

Protected API Methods

Get My Songs

<?php
$albums = $music_api->getMySongs();
API_TOKEN="Txxxxxxxxxxxxxxx"
API_SECRET_KEY="Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
NONCE=`date +%s`
SIGNATURE=$(echo -en "GET\nhttps://music.tokenly.com/api/v1/music/mysongs\n{}\n${API_TOKEN}\n${NONCE}" \
    | openssl dgst -sha256 -hmac "${API_SECRET_KEY}" -binary | base64)
curl -X GET \
    -H "X-TOKENLY-AUTH-API-TOKEN: ${API_TOKEN}" \
    -H "X-TOKENLY-AUTH-NONCE: ${NONCE}" \
    -H "X-TOKENLY-AUTH-SIGNATURE: ${SIGNATURE}" \
    https://music.tokenly.com/api/v1/music/mysongs

The above command returns data structured like this:

[
    {
        "id": "d2e5fbb2-ee81-49bc-a791-0464ff01f6a1",
        "name": "The Banana Stands' Lament",
        "tokens": [
            "LITTLECOLOR",
            "MTMYEARONE",
            "MTMCOLLECTOR",
            "MTMPRODUCER"
        ],
        "description": "",
        "performers": "Mind To Matter",
        "composers": "Adam B. Levine",
        "releaseDate": "2016-03-26T20:31:19+0000",
        "lyrics": "",
        "credits": "",
        "copyright": "Adam B. Levine 2016",
        "ownership": "Adam B. Levine",
        "usageRights": "",
        "usageProhbitions": "",
        "bitcoinAddress": "1GJchZwagFFxXMUnRyQFVDe8QSKb9mJKXS",
        "other": "",
        "downloadUrl": "https://s3.amazonaws.com/tokenly-music/u-xxxxx/a-xxxxx/s-xxxxx/xxxxx.mp3",
        "downloadSize": 3519927,
        "artistProfileId": "4d1bf328-8fb3-4fef-ac65-b4f71b52ce03"
    }
]

Lists all songs available to the user owning the API token. The data returned includes a download URL for each song.

HTTP Request

GET https://music.tokenly.com/api/v1/music/mysongs

Store Playlists

<?php
$music_api->storePlaylists($playlists);
API_TOKEN="Txxxxxxxxxxxxxxx"
API_SECRET_KEY="Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
NONCE=`date +%s`
SIGNATURE=$(echo -en "PUT\nhttps://music.tokenly.com/api/v1/playlists\n{\"playlist_1\":[{\"id\":\"songid1\"},{\"id\":\"songid2\"}]}\n${API_TOKEN}\n${NONCE}" \
    | openssl dgst -sha256 -hmac "${API_SECRET_KEY}" -binary | base64)
curl -X PUT \
    -H "Content-Type: application/json" \
    -H "X-TOKENLY-AUTH-API-TOKEN: ${API_TOKEN}" \
    -H "X-TOKENLY-AUTH-NONCE: ${NONCE}" \
    -H "X-TOKENLY-AUTH-SIGNATURE: ${SIGNATURE}" \
    -d '{"playlist_1":[{"id":"songid1"},{"id":"songid2"}]}' \
    https://music.tokenly.com/api/v1/playlists

The above command returns data structured like this:

{
    "id": "3767d136-7ef4-4112-9dfe-71a0b6261caf"
}

Stores playlist data for the user owning the API token. The data returned is only an id.

HTTP Request

PUT https://music.tokenly.com/api/v1/playlists

PUT Parameters

The playlist data formatted as a JSON encoded string. The API will return an error if the data is larger than 4 Kb.

Retrieve Playlists

<?php
$playlists = $music_api->getPlaylists();
API_TOKEN="Txxxxxxxxxxxxxxx"
API_SECRET_KEY="Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
NONCE=`date +%s`
SIGNATURE=$(echo -en "GET\nhttps://music.tokenly.com/api/v1/playlists\n{}\n${API_TOKEN}\n${NONCE}" \
    | openssl dgst -sha256 -hmac "${API_SECRET_KEY}" -binary | base64)
curl -X GET \
    -H "Content-Type: application/json" \
    -H "X-TOKENLY-AUTH-API-TOKEN: ${API_TOKEN}" \
    -H "X-TOKENLY-AUTH-NONCE: ${NONCE}" \
    -H "X-TOKENLY-AUTH-SIGNATURE: ${SIGNATURE}" \
    https://music.tokenly.com/api/v1/playlists

The above command returns data structured like this:

{
    "playlist_1": [
        {
            "id": "songid1"
        },
        {
            "id": "songid2"
        }
    ]
}

Retrieves playlist data for the user owning the API token.

HTTP Request

GET https://music.tokenly.com/api/v1/playlists

Store Profile

<?php
$music_api->storeProfile($profile);
API_TOKEN="Txxxxxxxxxxxxxxx"
API_SECRET_KEY="Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
NONCE=`date +%s`
SIGNATURE=$(echo -en "PUT\nhttps://music.tokenly.com/api/v1/profile\n{\"bio\":{\"I luve music.\"}}\n${API_TOKEN}\n${NONCE}" \
    | openssl dgst -sha256 -hmac "${API_SECRET_KEY}" -binary | base64)
curl -X PUT \
    -H "Content-Type: application/json" \
    -H "X-TOKENLY-AUTH-API-TOKEN: ${API_TOKEN}" \
    -H "X-TOKENLY-AUTH-NONCE: ${NONCE}" \
    -H "X-TOKENLY-AUTH-SIGNATURE: ${SIGNATURE}" \
    -d '{"bio":{"I luv music."}' \
    https://music.tokenly.com/api/v1/profile

The above command returns data structured like this:

{
    "id": "11513219-9ba7-44c7-b221-707edf2a10b0"
}

Stores public profile data for the user owning the API token. The data returned is only an id.

HTTP Request

PUT https://music.tokenly.com/api/v1/profile

PUT Parameters

The profile data formatted as a JSON encoded string. The API will return an error if the data is larger than 4 Kb.

Retrieve Profile

<?php
$profile = $music_api->getProfile();
API_TOKEN="Txxxxxxxxxxxxxxx"
API_SECRET_KEY="Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
NONCE=`date +%s`
SIGNATURE=$(echo -en "GET\nhttps://music.tokenly.com/api/v1/profile\n{}\n${API_TOKEN}\n${NONCE}" \
    | openssl dgst -sha256 -hmac "${API_SECRET_KEY}" -binary | base64)
curl -X GET \
    -H "Content-Type: application/json" \
    -H "X-TOKENLY-AUTH-API-TOKEN: ${API_TOKEN}" \
    -H "X-TOKENLY-AUTH-NONCE: ${NONCE}" \
    -H "X-TOKENLY-AUTH-SIGNATURE: ${SIGNATURE}" \
    https://music.tokenly.com/api/v1/profile

The above command returns data structured like this:

{
    "bio": "I luv music."
}

Retrieves profile data for the user owning the API token.

HTTP Request

GET https://music.tokenly.com/api/v1/profile

Get Credits Balance

<?php
$profile = $music_api->getCreditsBalance();
API_TOKEN="Txxxxxxxxxxxxxxx"
API_SECRET_KEY="Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
NONCE=`date +%s`
SIGNATURE=$(echo -en "GET\nhttps://music.tokenly.com/api/v1/credits/balance\n{}\n${API_TOKEN}\n${NONCE}" \
    | openssl dgst -sha256 -hmac "${API_SECRET_KEY}" -binary | base64)
curl -X GET \
    -H "Content-Type: application/json" \
    -H "X-TOKENLY-AUTH-API-TOKEN: ${API_TOKEN}" \
    -H "X-TOKENLY-AUTH-NONCE: ${NONCE}" \
    -H "X-TOKENLY-AUTH-SIGNATURE: ${SIGNATURE}" \
    https://music.tokenly.com/api/v1/credits/balance

The above command returns data structured like this:

{
    "balanceFloat": 1000,
    "balanceSat": 100000000000
}

Retrieves the credits balance for the user owning the API token.

HTTP Request

GET https://music.tokenly.com/api/v1/credits/balance

Query Parameters

Parameter Description
refresh Skip the cache and reload the balance from Tokenpass. (optional)

Authorize Stream

<?php
$song_uuid = "79c78547-ebf2-40d8-bbed-000000000001";
$profile = $music_api->authorizeStream($song_uuid);
API_TOKEN="Txxxxxxxxxxxxxxx"
API_SECRET_KEY="Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
NONCE=`date +%s`
SONG_UUID="79c78547-ebf2-40d8-bbed-000000000001"
SIGNATURE=$(echo -en "POST\nhttps://music.tokenly.com/api/v1/stream/${SONG_UUID}\n{}\n${API_TOKEN}\n${NONCE}" \
    | openssl dgst -sha256 -hmac "${API_SECRET_KEY}" -binary | base64)
curl -X POST \
    -H "Content-Type: application/json" \
    -H "X-TOKENLY-AUTH-API-TOKEN: ${API_TOKEN}" \
    -H "X-TOKENLY-AUTH-NONCE: ${NONCE}" \
    -H "X-TOKENLY-AUTH-SIGNATURE: ${SIGNATURE}" \
    https://music.tokenly.com/api/v1/stream/${SONG_UUID}

The above command returns data structured like this:

{
    "authorized": true,
    "balanceFloat": 97,
    "balanceSat": 9700000000,
    "authType": "credits",
    "token": null
}

Retrieves profile data for the user owning the API token.

The returned authType is “credits” or “token”. If the authType is token, then the token name used is included.

HTTP Request

POST https://music.tokenly.com/api/v1/stream/{songid}

URL Parameters

Parameter Description
songid The song identifier (UUID)

TCA Check

<?php
$statuses = $music_api->tcaCheck(['ALBUMONE'=>1, 'ALBUMTWO'=>1]);
API_TOKEN="Txxxxxxxxxxxxxxx"
API_SECRET_KEY="Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
NONCE=`date +%s`
SIGNATURE=$(echo -en "POST\nhttps://music.tokenly.com/api/v1/tca/status\n{\"tokens\": {\"ALBUMONE\":1, \"ALBUMTWO\":1}}\n${API_TOKEN}\n${NONCE}" \
    | openssl dgst -sha256 -hmac "${API_SECRET_KEY}" -binary | base64)
curl -X POST \
    -H "Content-Type: application/json" \
    -H "X-TOKENLY-AUTH-API-TOKEN: ${API_TOKEN}" \
    -H "X-TOKENLY-AUTH-NONCE: ${NONCE}" \
    -H "X-TOKENLY-AUTH-SIGNATURE: ${SIGNATURE}" \
    -d '{"tokens": {"ALBUMONE":1, "ALBUMTWO":1}}' \
    https://music.tokenly.com/api/v1/tca/status

The above command returns data structured like this:

{
    "access": {
        "ALBUMONE": true,
        "ALBUMTWO": false
    }
}

Returns the TCA (Token Controlled Access) status for the current user for multiple tokens.

HTTP Request

POST https://music.tokenly.com/api/v1/tca/status

POST Parameters

Parameter Description
tokens An object of token names and minimum amounts.
refresh Skip the cache and reload the balance from Tokenpass. (optional)

Logout

<?php
$profile = $music_api->logout();
API_TOKEN="Txxxxxxxxxxxxxxx"
API_SECRET_KEY="Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
NONCE=`date +%s`
SIGNATURE=$(echo -en "GET\nhttps://music.tokenly.com/api/v1/account/logout\n{}\n${API_TOKEN}\n${NONCE}" \
    | openssl dgst -sha256 -hmac "${API_SECRET_KEY}" -binary | base64)
curl -X GET \
    -H "Content-Type: application/json" \
    -H "X-TOKENLY-AUTH-API-TOKEN: ${API_TOKEN}" \
    -H "X-TOKENLY-AUTH-NONCE: ${NONCE}" \
    -H "X-TOKENLY-AUTH-SIGNATURE: ${SIGNATURE}" \
    https://music.tokenly.com/api/v1/account/logout

The above command returns data structured like this:

{
}

Logs out a user from all active sessions.

HTTP Request

GET https://music.tokenly.com/api/v1/account/logout

Errors

The Tokenly Music API uses the following error codes:

Error Code Name Meaning
403 Forbidden The credentials are wrong or missing
404 Not Found The resource is not found
405 Method Not Allowed You tried to access an endpoint with an invalid method
410 Gone The requested resource is no longer present
429 Too Many Requests Too Many Requests
500 Internal Server Error We had a problem with our server. Try again later.
503 Service Unavailable We’re temporarially offline for maintenance. Please try again later.