Data API
Overview
This document introduces the relevant content for DATA development integration.
Data Interface Authentication Login
The platform's externally published interface services (RESTful style Http services) require authentication login to ensure data security. Currently, only one authentication method is supported: Bearer Token.
Integration Preparation
You need to obtain a pair of client_id and client_secret from the platform. This is the unique identifier for your application, used to obtain the access_token.
Authentication
When you already have client_id and client_secret, you can obtain the access_token through the following steps:
Step 1: Generate Signature
The signature generation rule: client_id + current timestamp + client_secret, then perform MD5 encryption. The resulting 32-character uppercase string is the signature string.
-
Signature generation example:
- javascript
- c#
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js"></script>
<script>
const client = "输入你的 client_id"
const secret = "输入你的 client_secret"
const timestamp = Math.ceil(+new Date() / 1000) // 当前时间戳(十位)
const plaintext = `${client}${timestamp}${secret}` // 签名明文
const signature = CryptoJS.MD5(plaintext).toString().toUpperCase(); // 得到签名
console.log(`签名结果:${signature}`)
</script>using System.Security.Cryptography;
var client = "输入你的 client_id";
var secret = "输入你的 client_secret";
var timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds() / 1000; // 当前时间戳(十位)
var plaintext = $"{client}{timestamp}{secret}"; // 签名明文
var signature = Convert.ToHexString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(plaintext))); // 得到签名
Console.WriteLine($"签名结果:{signature}");
Step 2: Send Authentication Request
-
Request method: POST
-
Content-Type:
application/json -
Request parameters:
Parameter Type Required Description clientId string yes Client (provided by the platform) time number yes Current timestamp signature string yes Signature (generated by client_id + time + client_secret, then MD5 encrypted, the resulting 32-character uppercase string is the signature) -
Request example:
curl --location 'https://localhost/api/TokenAuth/Authenticate' \
--header 'Content-Type: application/json' \
--data '{
"clientId": "openapi",
"time": 1724753509317,
"signature": "B9DBA02F6223468F16E8250D8F080CFF"
}' -
Response parameters:
Parameter Sub-parameter Description code Status code data Result data accessToken Access token expireInSeconds Validity period (seconds) success Whether successful msg Error message -
Response example:
{
"code": 200,
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc0V4dGVybmFsIjpmYWxzZSwidXNlcklkIjoiNDMyNDMwMDg0OTY4Njc3Nzg1NyIsImFjY291bnQiOiJXZWxsaW5ndG9uQXBpIiwicmVhbE5hbWUiOiJXZWxsaW5ndG9uQXBpIiwidXNlclR5cGUiOiJkZGFfY2xpZW50Iiwic3lzdGVtIjoiSE9NRSIsImVtYWlsIjpudWxsLCJhdmF0YXIiOm51bGwsImdsb2JlUm9sZU5hbWUiOm51bGwsImNsaWVudFR5cGUiOjAsIm11c3RDaGFuZ2VQd2QiOmZhbHNlLCJleHAiOjE3Mjg4MDcyMDV9.J0oiH0hzYv72X65DZEOoAxDV6PsNuUuyKhNYkdlaD90",
"expireInSeconds": 86400
},
"success": true,
"msg": null
}