Skip to content

Brief Description

  • Global Request Header Explanation

Request Specification

Basic Information

  • Interface Protocol:HTTPS
  • Data Format:JSON
  • Request Method:GETPOST etc.

General Request Header

Parameter NameRequiredTypeexplain
AuthorizationstringUser authentication token, in the format of: Bearer <token>
Content-TypestringThe post request is of application/json type.

General Interface Response Format

Explanation of Response Parameters for the List without Data Entries

Parameter NameTypeexplain
codenumberResponse status code, for details please refer to the following. 后端响应状态码说明
messagestringResponse message prompt
dataObjectThe response data

Example of Response for the List with No Data

  {
	  "code": 200,
	  "message": "operate successfully",
	  "data": {}
  }

Response with data list, description of the data parameter

  • code, message, data Consistent with the above.
Parameter NameTypeexplain
pagenumberCurrent page page number
sizenumberData volume per page
totalnumberTotal number of data items
listArrayThe response data

Example of a response with a data list

json
{
  "code": 200,
  "message": "operate successfully",
  "data": {
    page: 1,
    size: 15,
    total: 66,
    list: []
  }
}

Signature mechanism

Signature Key Generation Method

  • Sort the request fields in the interface in ascending order based on their Ascii codes.
  • Format it as key1=val1&key2=val2&key3=val3…&key=md5_secret_key.
  • Encrypt the string generated in the previous step using MD5.

Signature Example

Required Parameter

json

{
  "amount": "100",
  "order_no": "ts3023423423",
  "key": "adesf235"
}

TypeScript Request Example

typescript

import * as crypto from 'crypto'

const payload = {
  amount: "100",
  order_no: "ts3023423423",
}

const secret = "adesf235" // md5秘钥

// 1. 排序(ASCII码升序)
const sortedKeys = Object.keys(payload).sort()

// 2. 拼接为 key1=val1&key2=val2... 的格式(不包含 key 字段)
const signingString = sortedKeys
  .filter(key => key !== 'key') // 去掉 key 字段
  .map(key => `${key}=${payload[key]}`)
  .join('&') + `&key=${secret}`

// 3. 进行 MD5 加密
const signature = crypto.createHash('md5').update(signingString).digest('hex')

console.log("签名前字符串:", signingString)
console.log("签名:", signature)

Note

  • For more questions regarding the global request interface, please consult the administrator.
  • Update Date: 2024-04-24