Starlink API

Interface Global Public Parameters

Parameter Name Variable Mandatory Description
appKey string true Interface caller identity certificate
timestamp long true Interface request timestamp (in milliseconds)
sign string true Summary of the content of this request
content string true The string encrypted by AES after the interface parameters are converted to json
version string true Interface version, if the interface details are not specified, please fill in 1

Interface Global Return Parameters

Parameter Name Variable Mandatory Description
status int true Request status, 200 if successful, please refer to http status code
msg string true Error message
data map true Data returned by the interface

1.0 Encryption

Sort the interface parameters. Note that each interface parameter must have a timestamp, which is equal to the public parameter timestamp.

After sorting, convert it into the form of Get request parameter, encrypt with MD5 digest, and use the hexadecimal output string as [sign] (The interface parameters must be sorted before md5 , otherwise, the string order and md5 value will be different, and it will not pass the verification).

 

public String sort(Map params) {

        List<Map.Entry<String, Object>> argList = new LinkedList<Map.Entry<String, Object>>();

        argList.addAll(params.entrySet());

        Collections.sort(argList, Map.Entry.comparingByKey());

        StringBuilder sb = new StringBuilder();

        for (Map.Entry<String, Object> item : argList) {

            String key = item.getKey();

            String val = String.valueOf(item.getValue());

            if (!(val == “” || val == null)) {

                sb.append(key + “=” + val + “&”);

            }

        }

        return SecureUtil.md5(sb.toString());

Convert the interface parameters into a json string. Encrypt the json string with AES using a private key. Output the string using base64, and use it as [content].

import org.apache.tomcat.util.buf.HexUtils;

 

import javax.crypto.Cipher;

import javax.crypto.spec.SecretKeySpec;

import java.security.Key;

 

public String encrypt(String content, String privateKey) throws Exception {

        Cipher cipher = Cipher.getInstance(“AES”);

        byte[] bs = HexUtils.fromHexString(privateKey);

        Key key = new SecretKeySpec(bs,“AES”);

        cipher.init(Cipher.ENCRYPT_MODE, key);

        byte[] p = content.getBytes(“UTF-8”);

        byte[] result = cipher.doFinal(p);

        String encoded = Base64Encoder.encode(result);

        return encoded;

    }

If using PHP, please refer to the following code.

function getSign($params)

{

    ksort($params);

    $str = http_build_query($params);

    $decodeStr = urldecode($str)

 

    return md5($decodeStr . ‘&’);

}

 

function getContent($params)

{

    ksort($params);

    $input = json_encode($params);

 

    $key = hex2bin($this->privateKey);

 

    $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);

    $input = pkcs5_pad($input, $size);

    $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, , MCRYPT_MODE_ECB, );

    $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);

    mcrypt_generic_init($td, $key, $iv);

    $data = mcrypt_generic($td, $input);

    mcrypt_generic_deinit($td);

    mcrypt_module_close($td);

    $data = base64_encode($data);

 

    return $data;

}

 

/**

 * Filing Method pkcs5

 * @param String text Original String

 * @param String blocksize   Encryption Size

 * @return String

 */

function pkcs5_pad($text, $blocksize) {

    $pad = $blocksize (strlen($text) % $blocksize);

    return $text . str_repeat(chr($pad), $pad);

2.0 Interface List

2.1 Notification Interface

URL: /notice/download

Request method: GET

Interface description: Every time the caller’s user downloads the audio, the uid of the audio needs to be sent to this interface, so that our operation team can adjust the operation strategy according to the statistical data.

Parameter List

Parameter Name

Variable

Mandatory

Description

timestamp

long

true

Timestamp  (in milliseconds), must equal to the timestamp in the public parameter

uid

string

true

Track UID

 

Interface Return Data (please refer to the prompt for the reason for abnormal data)

Parameter Name

Variable

Mandatory

Description

null

null

null

null

2.2 Upload Statistical Data

URL: /notice/statistics

Request method: GET

Parameter List

Parameter Name Variable Mandatory Description
timestamp long true Timestamp (in milliseconds), must be equal to the timestamp in the public parameter
download int true Downloads
play int true Play volume
orders int true Order volume
startTime long true The start time of this recording
endTime long true The end time of this recording

 

Interface Return Data (please refer to the prompt for the reason of abnormal data)

Parameter Name

Variable

Mandatory

Description

null

null

null

null

2.3 Order Notification

URL: /notice/order

Request method: GET

Interface description: Every time the caller’s user purchases the audio, the UID of the audio needs to be sent to this interface so that our operation team can adjust the operation strategy according to the statistical data.

Parameter List

Parameter Name

Variable

Mandatory

Description

timestamp

long

true

Timestamp (in milliseconds), must equal to the timestamp in the public parameter

uid

string

true

Track UID

 

Interface Return Data (please refer to the prompt for the reason of abnormal data)

Parameter Name

Variable

Mandatory

Description

null

null

null

null

2.4 Play Notification

URL: /notice/play

Request method: GET

Interface description: Every time the caller’s user plays the audio, the UID of the audio needs to be sent to this interface so that our operation team can adjust the operation strategy according to the statistical data.

Parameter List

Variable

Parameter

Mandatory

Description

timestamp

long

true

Timestamp (in milliseconds), mustequal to the timestamp in the public parameter 

uid

string

true

Track UID

 

Interface Return Data (please refer to the prompt for the reason of abnormal data)

Parameter Name

Variable

Mandatory

Description

null

null

null

null

3.0 Tag Interface

Get all tags.

  1. URL: /tag
  2. Request method: GET

Parameter List

Variable

Parameter

Mandatory

Description

timestamp

long

true

Timestamp (in milliseconds)

page

int

false

Pagination parameters – the current number of pages

size

int

false

Pagination  parameters – the amount of data per page

 

Interface Return Parameters

Variable

Parameter

Mandatory

Description

records

array

true

List of tags

total

int

false

The total number of tags – if no pagination parameter is sent, then this parameter will not be returned

 

Example of Return Interface Parameters

{

  “msg”: “”,

  “data”: {

    “total”: 20,

    “records”: [

      {

        “uid”: “MtCmVMOzZ”,

        “name”: “Genre”

      }

    ]

  },

  “status”: 200

}

4.0 Track Interface

Get all tags

  1. URL: /track/link
  2. Request method: GET

Parameter List

Variable Parameter Mandatory Description
timestamp long true Timestamp (in milliseconds)
uid string true Track UID

 

Interface Return Parameters

Variable

Parameter

Mandatory

Description

data

string

true

String of lossless audio download/streaming  link 

 

Note: This link has an expiration time, which expires in five minutes by default, so a new authorized audio link needs to be requested every five minutes.

Example of Return Interface Parameters

 

{

  “msg”: “”,

  “data”: “http://www.kanjian.com/track.mp3?id=1213”,

  “status”: 200

}

4.1 Search Track

URL: /track/search

Request method: GET

Interface description: If the business needs more search criteria, please communicate with us to open the interface.

Parameter list

Variable

Parameter

Mandatory

Description

timestamp

long

true

Timestamp (in milliseconds)

tags

array<string>

false

Track’s Tag UID

name

string

false

Track name (keyword search)

page

int

false

Pagination parameters – the current number of pages

size

int

false

Pagination  parameters – the amount of data per page

trackUid

array<string>

false

Batch query track information based on the UID

 

Interface Return Parameters

Variable

Parameter

Mandatory

Description

records

array

true

Record

total

int

false

Total amount of data

 

Records Internal Data Structure

Variable

Parameter

Mandatory

Description

name

string

true

Track Name

uid

string

true

Track UID

artist

string

true

Artist

composer

string

true

Songwriter

lyricist

string

true

Lyricist

isrc

string

true

Track ISRC code

upc

string

true

Album UPC code

bpm

int

true

Music speed in beats per minute

fileSize

int

true

File size

duration

int

true

Duration

cover

string

true

Cover image URL

wavePicUrl

string

true

Waveform URL

tag

array

true

An array of track’s tags, 

the data structure refers  tag interface

description

string

true

A short description of the audio

 

Example of Interface Return Parameters

{

  “msg”: “”,

  “data”: {

    “records”: [

      {

        “name”: “Blue Moon”,

        “uid”: “DLOqfKKRX”,

        “artist”: “Akin”,

        “composer”: “Akin”,

        “lyricist”: “Akin”,

        “isrc”: “HKC371602831”,

        “upc”: “6930043306798”,

        “bpm”: 153,

        “fileSize”: 45080142,

        “duration”: 255,

        “cover”: “http://library.kanjian.com/6930043306798/cover.png”,

        “wavePicUrl”: “http://library.kanjian.com/6930043306798/HKC371602831.png”,

        “description”: “The single Blue moon will be included on Akin’s upcoming second Mixtape: [HURT&AWAKE]. Look forward to it. (Lyricist/Composer: Akin Arranger: Jock/Akin)-“,

        “tag”: [

          {

            “uid”: “KzG7Nsy9h”,

            “name”: “DISCO”

          }

        ]

      }

    ],

    “total”: 1

  },

  “status”: 200

}

4.2 Get Audio Streaming Link

URL: /track/listen

Request method: GET

Parameter list

Variable

Parameter

Mandatory

Description

timestamp

long

true

Timestamp (in milliseconds)

uid

string

true

Track UID

 

Interface Return Parameters

Variable

Parameter

Mandatory

Description

data

string

true

String of lossy audio streaming/download link 

 

Note: This link has an expiration time, which expires in five minutes by default, so a new authorised audio link needs to be requested every five minutes.

Example of Interface Return Parameters

{

  “msg”: “”,

  “data”: “http://www.kanjian.com/track.mp3?id=1213”,

  “status”: 200

}

  “status”: 200

}