开发者平台(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
}请求参数
| 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|---|
| body | body | AgentDevLoginReq | 否 | AgentDevLoginReq | none |
签名(MD5加密)
获取signature: (phoneNumber + agentId + secretKey + timestamp)md5加密验证返回示例
200 Response
{"code":0,"msg":"string","success":true}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | OK | AgentResult«string» |
| 201 | Created | Created | None |
| 401 | Unauthorized | Unauthorized | None |
| 403 | Forbidden | Forbidden | None |
| 404 | Not Found | Not Found | None |
返回数据结构
状态码 200
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » additionalProperties | object | false | none | none |
POST 获取用户accessToken
POST /api/getAccessToken
Body 请求参数
json
{
"credential": "string",
"agentId": 0,
}请求参数
| 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|---|
| body | body | AccessTokenReq | 否 | AccessTokenReq | none |
返回示例
200 Response
{"code":0,"data":{"accessToken":"string","expiresIn":0,"refreshToken":"string"},"msg":"string","success":true}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | OK | AgentResult«TokenResponse» |
| 201 | Created | Created | None |
| 401 | Unauthorized | Unauthorized | None |
| 403 | Forbidden | Forbidden | None |
| 404 | Not Found | Not Found | None |
GET 获取用户信息
GET /api/getUserInfo
请求参数
| 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|---|
| token | query | string | 是 | token | |
| agentId | query | integer(int64) | 是 | agentId |
返回示例
200 Response
{"code":0,"data":{"avatar":"string","email":"string","nickName":"string","phoneNumber":"string"},"msg":"string","success":true}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | OK | AgentResult«AgentUserInfo» |
| 401 | Unauthorized | Unauthorized | None |
| 403 | Forbidden | Forbidden | None |
| 404 | Not Found | Not Found | None |
GET 订单号查询订单
GET /api/outTradeNo/
请求参数
| 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|---|
| outTradeNo | path | string | 是 | outTradeNo |
返回示例
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}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | OK | AgentResult«AgentBillRecordVo» |
| 401 | Unauthorized | Unauthorized | None |
| 403 | Forbidden | Forbidden | None |
| 404 | Not Found | Not Found | None |
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\nJava代码示例:String.format("%s\n%s\n%s\n",agentId,timestamp,nonce)
计算签名值
使用智能体秘钥对签名串进行HmacSHA256签名,并对签名结果进行Base64编码得到签名值signature。
请求参数
| 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|---|
| body | body | PayAgentReq | 否 | PayAgentReq | none |
返回示例
200 Response
{"code":0,"data":{"outTradeNo":"string"},"msg":"string","success":true}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | OK | AgentResult«PayAgentVo» |
| 201 | Created | Created | None |
| 401 | Unauthorized | Unauthorized | None |
| 403 | Forbidden | Forbidden | None |
| 404 | Not Found | Not Found | None |
POST 刷新token
POST /api/refreshToken
Body 请求参数
json
{
"refreshToken": "string",
"agentId": 0,
}请求参数
| 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|---|
| body | body | RefreshTokenReq | 否 | RefreshTokenReq | none |
返回示例
200 Response
{"code":0,"data":{"accessToken":"string","expiresIn":0,"refreshToken":"string"},"msg":"string","success":true}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | OK | AgentResult«TokenResponse» |
| 201 | Created | Created | None |
| 401 | Unauthorized | Unauthorized | None |
| 403 | Forbidden | Forbidden | None |
| 404 | Not Found | Not Found | None |
错误码
公共错误码
| 状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
| 10001 | PARAMETER_VALIDATION_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
| 10002 | SYSTEM_ERROR | 系统异常 | 系统异常,请稍后重试 |
| 10003 | SIGN_ERROR | 签名错误或已失效 | 请参阅签名常见问题 |
| 10004 | TOKEN_NOT_EXISTS | 用户凭证错误或已失效 | 请参阅用户凭证接口 |
| 10005 | TOKEN_EXPIRED | 用户凭证已过期 | 请重新获取用户凭证 |
业务错误码
| 状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
| 20001 | AGENT_NOT_EXISTS | 智能体不存在 | 请检查agentId是否正确 |
| 20002 | ORDER_NOT_EXIST | 订单不存在 | 请检查outTradeNo是否正确 |
| 20003 | AGENT_NO_CHARGE | 非收费智能体 | 请检查智能体应用平台是否设置收费 |
| 20004 | INSUFFICIENT_BALANCE | 用户余额不足 | 用户余额不足,请前往应用平台充值 |
| 20005 | AGENT_SECRET_KEY_ERROR | 智能体秘钥错误 | 智能体秘钥错误,请前往应用平台查看智能体秘钥 |
数据模型
AccessTokenReq
json
{
"credential": "string",
"agentId": 0
}AccessTokenReq
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| credential | string | true | none | 用户凭证 | |
| agentId | Long | true | none | 智能体ID |
AgentDevLoginReq
json
{
"agentId": 0,
"phoneNumber": "string",
"signature": "string",
"timestamp": 0
}AgentDevLoginReq
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| agentId | integer(int64) | true | none | 智能体id | |
| phoneNumber | string | true | none | 手机号 | |
| signature | string | true | none | 签名 | |
| timestamp | integer(int64) | true | none | 时间戳 |
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
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| agentId | integer(int64) | false | none | none | |
| attach | string | false | none | none | |
| billId | integer(int64) | false | none | none | |
| description | string | false | none | none | |
| inputTokens | integer(int64) | false | none | none | |
| outTradeNo | string | false | none | none | |
| outputTokens | integer(int64) | false | none | none | |
| phoneNum | string | false | none | none | |
| project | string | false | none | none | |
| requestTime | string(date-time) | false | none | none | |
| responseTime | string(date-time) | false | none | none | |
| serviceFee | number(bigdecimal) | false | none | none | |
| status | string | false | none | none | |
| totalCost | number(bigdecimal) | false | none | none |
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»
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| code | integer(int32) | false | none | none | |
| data | AgentBillRecordVo | false | none | none | |
| msg | string | false | none | none | |
| success | boolean | false | none | none |
AgentResult«AgentUserInfo»
json
{
"code": 0,
"data": {
"avatar": "string",
"email": "string",
"nickName": "string",
"phoneNumber": "string"
},
"msg": "string",
"success": true
}AgentResult«AgentUserInfo»
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| code | integer(int32) | false | none | none | |
| data | AgentUserInfo | false | none | none | |
| msg | string | false | none | none | |
| success | boolean | false | none | none |
AgentResult«PayAgentVo»
json
{
"code": 0,
"data": {
"outTradeNo": "string"
},
"msg": "string",
"success": true
}AgentResult«PayAgentVo»
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| code | integer(int32) | false | none | none | |
| data | PayAgentVo | false | none | none | |
| msg | string | false | none | none | |
| success | boolean | false | none | none |
AgentResult«TokenResponse»
json
{
"code": 0,
"data": {
"accessToken": "string",
"expiresIn": 0,
"refreshToken": "string"
},
"msg": "string",
"success": true
}AgentResult«TokenResponse»
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| code | integer(int32) | false | none | none | |
| data | TokenResponse | false | none | none | |
| msg | string | false | none | none | |
| success | boolean | false | none | none |
AgentUserInfo
json
{
"avatar": "string",
"email": "string",
"nickName": "string",
"phoneNumber": "string"
}AgentUserInfo
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| avatar | string | false | none | 用户头像 | |
| string | false | none | 邮箱 | ||
| nickName | string | false | none | 用户昵称 | |
| phoneNumber | string | false | none | 手机号码 |
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
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| agentId | integer(int64) | true | none | 智能体id | |
| amount | number(bigdecimal) | true | none | 支付金额 | |
| attach | string | false | none | 商户数据包 | |
| description | string | false | none | 描述 | |
| inputTokens | integer(int64) | false | none | 输入token用量 | |
| nonce | string | true | none | 随机数 | |
| outputTokens | integer(int64) | false | none | 输出token用量 | |
| project | string | false | none | 扣费项目 | |
| signature | string | true | none | 签名 | |
| timestamp | integer(int64) | true | none | 时间戳 | |
| token | string | true | none | token |
RefreshTokenReq
json
{
"agentId": 0,
"refreshToken": "string"
}RefreshTokenReq
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| agentId | integer(int64) | true | none | 智能体ID | |
| refreshToken | string | true | none | 刷新token |
PayAgentVo
json
{
"outTradeNo": "string"
}PayAgentVo
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| outTradeNo | string | false | none | 订单号 |
TokenResponse
json
{
"accessToken": "string",
"expiresIn": 0,
"refreshToken": "string"
}TokenResponse
属性
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| accessToken | string | false | none | 访问令牌 | |
| expiresIn | integer(int64) | false | none | 令牌过期时间 | |
| refreshToken | string | false | none | 刷新令牌 |