Skip to content

开发者平台(API文档)

Base URLs:

Authentication

  • API Key (Authorization)
    • Parameter Name: Authorization, in: header.

POST 开发者登录

POST /api/devLogin

Body 请求参数

json
{
  "agentId": 0,
  "phoneNumber": "string",
  "signature": "string",
  "timestamp": 0
}

请求参数

名称位置类型必选中文名说明
bodybodyAgentDevLoginReqAgentDevLoginReqnone

签名(MD5加密)

获取signature: (phoneNumber + agentId + secretKey + timestamp)md5加密验证

返回示例

200 Response

{"code":0,"msg":"string","success":true}

返回结果

状态码状态码含义说明数据模型
200OKOKAgentResult«string»
201CreatedCreatedNone
401UnauthorizedUnauthorizedNone
403ForbiddenForbiddenNone
404Not FoundNot FoundNone

返回数据结构

状态码 200

名称类型必选约束中文名说明
» additionalPropertiesobjectfalsenonenone

POST 获取用户accessToken

POST /api/getAccessToken

Body 请求参数

json
{
  "credential": "string",
  "agentId": 0,
}

请求参数

名称位置类型必选中文名说明
bodybodyAccessTokenReqAccessTokenReqnone

返回示例

200 Response

{"code":0,"data":{"accessToken":"string","expiresIn":0,"refreshToken":"string"},"msg":"string","success":true}

返回结果

状态码状态码含义说明数据模型
200OKOKAgentResult«TokenResponse»
201CreatedCreatedNone
401UnauthorizedUnauthorizedNone
403ForbiddenForbiddenNone
404Not FoundNot FoundNone

GET 获取用户信息

GET /api/getUserInfo

请求参数

名称位置类型必选中文名说明
tokenquerystringtoken
agentIdqueryinteger(int64)agentId

返回示例

200 Response

{"code":0,"data":{"avatar":"string","email":"string","nickName":"string","phoneNumber":"string"},"msg":"string","success":true}

返回结果

状态码状态码含义说明数据模型
200OKOKAgentResult«AgentUserInfo»
401UnauthorizedUnauthorizedNone
403ForbiddenForbiddenNone
404Not FoundNot FoundNone

GET 订单号查询订单

GET /api/outTradeNo/

请求参数

名称位置类型必选中文名说明
outTradeNopathstringoutTradeNo

返回示例

200 Response

{"code":0,"data":{"agentId":0,"attach":"string","billId":0,"description":"string","inputTokens":0,"outTradeNo":"string","outputTokens":0,"phoneNum":"string","project":"string","requestTime":"2019-08-24T14:15:22Z","responseTime":"2019-08-24T14:15:22Z","serviceFee":0,"status":"string","totalCost":0},"msg":"string","success":true}

返回结果

状态码状态码含义说明数据模型
200OKOKAgentResult«AgentBillRecordVo»
401UnauthorizedUnauthorizedNone
403ForbiddenForbiddenNone
404Not FoundNot FoundNone

POST 支付

POST /api/paying

Body 请求参数

json
{
  "agentId": 0,
  "amount": 0,
  "attach": "string",
  "description": "string",
  "inputTokens": 0,
  "nonce": "string",
  "outputTokens": 0,
  "project": "string",
  "signature": "string",
  "timestamp": 0,
  "token": "string"
}

构造签名串

签名串一共有三行,每一行为一个参数。结尾以\n(换行符,ASCII编码值为0x0A)结束,包括最后一行。

agentId\n
时间戳\n
随机字符串\n

第一步,获取agentId

第二步,获取发起请求时的系统当前时间戳,即格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总毫秒数(13位数字),作为请求时间戳。支付系统会拒绝处理超过5分钟前发起的请求,请开发者保持自身系统的时间准确。

第三步,生成一个请求随机串,我们推荐生成随机数算法如下:调用随机数函数生成,将得到的值转换为字符串。

第四步,按照前述规则,构造的请求签名串如下:

709136840667141\n 
1754624383\n 
593BEC0C930BF1AFEB40B4A08C8FB242\n

Java代码示例:String.format("%s\n%s\n%s\n",agentId,timestamp,nonce)

计算签名值

使用智能体秘钥对签名串进行HmacSHA256签名,并对签名结果进行Base64编码得到签名值signature。

请求参数

名称位置类型必选中文名说明
bodybodyPayAgentReqPayAgentReqnone

返回示例

200 Response

{"code":0,"data":{"outTradeNo":"string"},"msg":"string","success":true}

返回结果

状态码状态码含义说明数据模型
200OKOKAgentResult«PayAgentVo»
201CreatedCreatedNone
401UnauthorizedUnauthorizedNone
403ForbiddenForbiddenNone
404Not FoundNot FoundNone

POST 刷新token

POST /api/refreshToken

Body 请求参数

json
{
  "refreshToken": "string",
  "agentId": 0,
}

请求参数

名称位置类型必选中文名说明
bodybodyRefreshTokenReqRefreshTokenReqnone

返回示例

200 Response

{"code":0,"data":{"accessToken":"string","expiresIn":0,"refreshToken":"string"},"msg":"string","success":true}

返回结果

状态码状态码含义说明数据模型
200OKOKAgentResult«TokenResponse»
201CreatedCreatedNone
401UnauthorizedUnauthorizedNone
403ForbiddenForbiddenNone
404Not FoundNot FoundNone

错误码

公共错误码

状态码错误码描述解决方案
10001PARAMETER_VALIDATION_ERROR参数错误请根据错误提示正确传入参数
10002SYSTEM_ERROR系统异常系统异常,请稍后重试
10003SIGN_ERROR签名错误或已失效请参阅签名常见问题
10004TOKEN_NOT_EXISTS用户凭证错误或已失效请参阅用户凭证接口
10005TOKEN_EXPIRED用户凭证已过期请重新获取用户凭证

业务错误码

状态码错误码描述解决方案
20001AGENT_NOT_EXISTS智能体不存在请检查agentId是否正确
20002ORDER_NOT_EXIST订单不存在请检查outTradeNo是否正确
20003AGENT_NO_CHARGE非收费智能体请检查智能体应用平台是否设置收费
20004INSUFFICIENT_BALANCE用户余额不足用户余额不足,请前往应用平台充值
20005AGENT_SECRET_KEY_ERROR智能体秘钥错误智能体秘钥错误,请前往应用平台查看智能体秘钥

数据模型

AccessTokenReq

json
{
  "credential": "string",
  "agentId": 0
}

AccessTokenReq

属性

名称类型必选约束中文名说明
credentialstringtruenone用户凭证
agentIdLongtruenone智能体ID

AgentDevLoginReq

json
{
  "agentId": 0,
  "phoneNumber": "string",
  "signature": "string",
  "timestamp": 0
}

AgentDevLoginReq

属性

名称类型必选约束中文名说明
agentIdinteger(int64)truenone智能体id
phoneNumberstringtruenone手机号
signaturestringtruenone签名
timestampinteger(int64)truenone时间戳

AgentBillRecordVo

json
{
  "agentId": 0,
  "attach": "string",
  "billId": 0,
  "description": "string",
  "inputTokens": 0,
  "outTradeNo": "string",
  "outputTokens": 0,
  "phoneNum": "string",
  "project": "string",
  "requestTime": "2019-08-24T14:15:22Z",
  "responseTime": "2019-08-24T14:15:22Z",
  "serviceFee": 0,
  "status": "string",
  "totalCost": 0
}

AgentBillRecordVo

属性

名称类型必选约束中文名说明
agentIdinteger(int64)falsenonenone
attachstringfalsenonenone
billIdinteger(int64)falsenonenone
descriptionstringfalsenonenone
inputTokensinteger(int64)falsenonenone
outTradeNostringfalsenonenone
outputTokensinteger(int64)falsenonenone
phoneNumstringfalsenonenone
projectstringfalsenonenone
requestTimestring(date-time)falsenonenone
responseTimestring(date-time)falsenonenone
serviceFeenumber(bigdecimal)falsenonenone
statusstringfalsenonenone
totalCostnumber(bigdecimal)falsenonenone

AgentResult«AgentBillRecordVo»

json
{
  "code": 0,
  "data": {
    "agentId": 0,
    "attach": "string",
    "billId": 0,
    "description": "string",
    "inputTokens": 0,
    "outTradeNo": "string",
    "outputTokens": 0,
    "phoneNum": "string",
    "project": "string",
    "requestTime": "2019-08-24T14:15:22Z",
    "responseTime": "2019-08-24T14:15:22Z",
    "serviceFee": 0,
    "status": "string",
    "totalCost": 0
  },
  "msg": "string",
  "success": true
}

AgentResult«AgentBillRecordVo»

属性

名称类型必选约束中文名说明
codeinteger(int32)falsenonenone
dataAgentBillRecordVofalsenonenone
msgstringfalsenonenone
successbooleanfalsenonenone

AgentResult«AgentUserInfo»

json
{
  "code": 0,
  "data": {
    "avatar": "string",
    "email": "string",
    "nickName": "string",
    "phoneNumber": "string"
  },
  "msg": "string",
  "success": true
}

AgentResult«AgentUserInfo»

属性

名称类型必选约束中文名说明
codeinteger(int32)falsenonenone
dataAgentUserInfofalsenonenone
msgstringfalsenonenone
successbooleanfalsenonenone

AgentResult«PayAgentVo»

json
{
  "code": 0,
  "data": {
    "outTradeNo": "string"
  },
  "msg": "string",
  "success": true
}

AgentResult«PayAgentVo»

属性

名称类型必选约束中文名说明
codeinteger(int32)falsenonenone
dataPayAgentVofalsenonenone
msgstringfalsenonenone
successbooleanfalsenonenone

AgentResult«TokenResponse»

json
{
  "code": 0,
  "data": {
    "accessToken": "string",
    "expiresIn": 0,
    "refreshToken": "string"
  },
  "msg": "string",
  "success": true
}

AgentResult«TokenResponse»

属性

名称类型必选约束中文名说明
codeinteger(int32)falsenonenone
dataTokenResponsefalsenonenone
msgstringfalsenonenone
successbooleanfalsenonenone

AgentUserInfo

json
{
  "avatar": "string",
  "email": "string",
  "nickName": "string",
  "phoneNumber": "string"
}

AgentUserInfo

属性

名称类型必选约束中文名说明
avatarstringfalsenone用户头像
emailstringfalsenone邮箱
nickNamestringfalsenone用户昵称
phoneNumberstringfalsenone手机号码

PayAgentReq

json
{
  "agentId": 0,
  "amount": 0,
  "attach": "string",
  "description": "string",
  "inputTokens": 0,
  "nonce": "string",
  "outputTokens": 0,
  "project": "string",
  "signature": "string",
  "timestamp": 0,
  "token": "string"
}

PayAgentReq

属性

名称类型必选约束中文名说明
agentIdinteger(int64)truenone智能体id
amountnumber(bigdecimal)truenone支付金额
attachstringfalsenone商户数据包
descriptionstringfalsenone描述
inputTokensinteger(int64)falsenone输入token用量
noncestringtruenone随机数
outputTokensinteger(int64)falsenone输出token用量
projectstringfalsenone扣费项目
signaturestringtruenone签名
timestampinteger(int64)truenone时间戳
tokenstringtruenonetoken

RefreshTokenReq

json
{
  "agentId": 0,
  "refreshToken": "string"
}

RefreshTokenReq

属性

名称类型必选约束中文名说明
agentIdinteger(int64)truenone智能体ID
refreshTokenstringtruenone刷新token

PayAgentVo

json
{
  "outTradeNo": "string"
}

PayAgentVo

属性

名称类型必选约束中文名说明
outTradeNostringfalsenone订单号

TokenResponse

json
{
  "accessToken": "string",
  "expiresIn": 0,
  "refreshToken": "string"
}

TokenResponse

属性

名称类型必选约束中文名说明
accessTokenstringfalsenone访问令牌
expiresIninteger(int64)falsenone令牌过期时间
refreshTokenstringfalsenone刷新令牌