Skip to main content

API Authorization

Tingyun provides data export APIs for all functional modules, and all APIs use the same authentication method.

Tingyun API Authentication​

Terminology​

api_key: A public key assigned by the platform to each administrator (main account), which is a string of characters used to verify identity when making API requests. You can obtain it from "User Center > Account Management > API".

secret_key: A private key used to generate digital signatures, which corresponds one-to-one with api_key. You can obtain it from "User Center > Account Management > API".

timestamp: The current request timestamp (millisecond timestamp).

auth: A digital signature generated through specific rules.

Authentication Description​

API Authentication

  1. Users send a request to the authentication service, which includes api_key, auth, and timestamp parameters.

  2. After receiving the request, the authentication service validates the parameters and returns an access_token upon successful validation.

  3. After receiving the access_token, you can use it to request APIs and obtain data.

access_token Description:

  1. The access_token is valid for 2 hours and expires after expiration.

Applying for access_token again will invalidate the previously applied access_token, with the most recently applied one taking precedence.

  1. After the access_token expires, you need to reapply. It is recommended to establish an access_token update mechanism so that it can be updated in time after expiration.

auth Calculation Rules:

  1. auth string concatenation

api_key="here_is_the_api_key_value"&secret_key="here_is_the_secret_key_value"&timestamp="here_is_the_current_request_millisecond_timestamp"

  1. auth string encryption: Encrypt the concatenated auth string with 32-bit lowercase MD5 encryption.

Obtaining access_token​

API endpoint: ${host}/my-api/auth/token?api_key=xxxxx&auth=xxxxx&timestamp=xxxxxx

Parameter Description

ParameterTypeDescription
api_keyStringIdentity verification code
authStringEncrypted signature
timestampLongCurrent request millisecond timestamp

Response Description

Example:

{

"code":200,

"msg":"success",

"access_token":" hbWUiOiLkupHljZfnlLXnvZEiLCJjb"

}

Description:

ParameterDescription
codeReturn code
msgReturn message
access_tokenaccess_token, used for identity authentication when calling Tingyun APIs

Return Code Description:

CodeMSGDescription
200successSuccess
40001Invalid timestampInvalid timestamp
40002Invalid api_keyInvalid api_key
40003Invalid authInvalid signature

Calling Tingyun APIs to Obtain Data​

To call Tingyun APIs to obtain data, you need to add the Authorization parameter in the request Headers, with the value "Bearer"+\${access_token}.

Authorization example:

Authorization= Bearer hbWUiOiLkupHljZfnlLXnvZEiLCJjb

Note: There is a space between Bearer and access_token.