轻易云集成平台对外部开放集成相关API接口 ,用户可以自定义应用授权,设置授权范围与白名单。
接口规范
● REST风格的API,使用HTTPS协议发送POST、GET请求调用接口。
● HTTPS请求头类型为 content-type: application/json
● 报文为UTF8编码,支持半角、中文、英文、数字、基本标点符号
● 请保持1分钟内60次的频率。如果接口响应请求太频繁,则5分钟后重新调用
接口文档说明
● 接口说明
用于接口描述、接口级别注意事项、敏感数据,以及建议调用方式等。
● 调用场景
用于说明接口适用对接的系统。
● 请求参数说明
描述了请求报文所有输入参数的含义及注意事项。
● 请求地址(url)
接口文档该部分描述了每个接口的测试和正式环境请求地址,注:不同接口变更“接口服务名”即可。
https://pro-service.xxxxx.xxxx
● 公共请求参数
每个接口都必须输入的参数。接口文档该部分阐述了请求报文中公共请求参数的含义及注意事项,参数详见下述表格。
● 业务请求参数
可根据业务不同,选择输入的参数。接口文档该部分阐述了请求报文中业务请求参数的含义及注意事项。
● 响应参数
接口文档该部分描述了所有响应参数的含义及注意事项
● 公共响应参数
接口文档该部分描述了,请求的当前接口,不论请求失败还是成功,一定会返回的参数,文档该部分描述了公共响应参数的含义。
● 业务响应参数
根据请求的参数输入值不同,做不同响应的参数,文档该部分描述了业务响应参数的含义
● 响应示例
调用接口后返回的json格式数据 ,需要使用json解析函数进行解析,使用Unicode转换具体的字段含义解释,并且给出了正常响应和异常响应两种响应示例。
目前已开发功能
○ 自定义应用授权
○ access_token认证
○ 写入(更新)集成方案数据
○ 查询集成方案数据
○ 激活源调度者
○ 激活目标调度者
○ IP白名单
○ 按方案设置权限
○ 请求日志记录
○ 访问速率控制
如果需要实现接口联调,比如写入数据之后,立即进行调度。可以使用两个接口实现这个功能,第一步:调用写入(更新)集成方案数据,第二步:激活目标调度者。
生成应用授权
一、进入菜单【API网关】【应用授权】可以开始新增应用授权
二、填写应用授权信息后保存,即可获得 app_key app_secret
轻易云开放API
access_token 认证
● 请求地址:http://{{host}}/v2/oauth
● 请求方式:POST
● Headers:content-type:application/json
● Body:raw json
● 需要访问令牌:否
java-OkHttp 请求示例
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"app_key\": \"012345678911\",\r\n \"app_secret\": \"11111111115555555555\"\r\n}");
Request request = new Request.Builder()
.url("http://www.ddhc.com/v2/oauth")
.method("POST", body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
向集成平台写入数据
● 请求地址:http://{{host}}/v2/open-api/business/{方案id}/store?access_token={access_token}
● 请求方式:POST
● Headers:content-type:application/json
● Body:raw json
● 需要访问令牌:是
注意点:需要和此对应的方案ID里面配置数据主键。如果没有配置,就会造成数据写入不成功
在集成平台可以定义请求参数是否必填。只有定义了必填项接口才会去检验检查。
如果不在集成平台定义该字段,接口仍然可以写入此数据
java-OkHttp 请求示例
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"content\": [\r\n {\r\n \"FStockId\": \"123123\",\r\n \"FNumber\": \"123123123\",\r\n \"FName\": \"123123\",\r\n \"arr\": [\r\n {\r\n \"gag\": \"233\"\r\n }\r\n ],\r\n \"obj\": {\r\n \"fsadfsdf\": \"dasd\"\r\n }\r\n }\r\n ]\r\n}");
Request request = new Request.Builder()
.url("http://www.ddhc.com/v2/open-api/business/0166a725-2b9a-30e4-91c5-3529176302c4/store?access_token=PSJthMmsVmc62d4c8528567be9b92435f0266cde05")
.method("POST", body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
从集成平台查询数据(列表)
● 请求地址:http://{{host}}/v2/open-api/business/{方案id}/query?access_token={access_token}
● 请求方式:POST
● Headers:content-type:application/json
● Body:raw json
● 需要访问令牌:是
请求参数 | 类型 | 是否必要 | 示例 | 说明 |
page | int | true | 1 | 页码 |
pageSize | int | true | 10 | 每页数据 |
begin_at | timestamp | true | 1613995390 | 起始时间(集成平台拉取时间) |
end_at | timestamp | true | 1616414590 | 结束时间 |
status | string | false | 0,1,2,3,4,5 | 数据状态:0待处理、1重复的、2已完成、3错误的、4负库存、5队列中 |
condition | object | false | | 查询条件 |
content.amount | any | false | 10 | 金额字段=10 |
content.shop_name | string | false | 天猫 | 店铺名称 包含 天猫 |
content.details.price | object | false | | |
$gt | number | false | 102 | 单价 大于 102 |
从集成平台查询数据(链路)
● 请求地址:http://{{host}}/v2/open-api/business/{方案id}/data-link?access_token={access_token}
● 请求方式:POST
● Headers:content-type:application/json
● Body:raw json
● 需要访问令牌:是
响应示例
{
"success": true,
"code": 0,
"message": "success",
"content": {
"links": [
{
"source": {
"dispatch": {
"trigger_begin": 0,
"adapter_class": "\\Adapter\\XXXX\\XXXXAdapter",
"trigger_end": 1646892733.15547
},
"job": {
"created_at": 1646892733.15547,
"handle_at": 1646892733.430782,
"response_at": 1646892733.425977,
"protocol": "http",
"SDK": "\\Adapter\\XXXXX\\SDK\\XXXXSDK",
"api": "/api/uri/test",
"exec": {
"url": "",
"method": "GET",
"header": {
"content-type": "application/json"
},
"content": {
"id": 100000000
}
}
},
"response": {
"code": "200",
"message": "操作成功",
"data": {},
"url": "https://api.xxxxxxxxxxxxxxxxxxx"
}
},
"target": {
"dispatch": {
"trigger_begin": 1646892733.612526,
"adapter_class": "\\Adapter\\XXXX\\XXXXAdapter",
"trigger_end": 1646892733.656357
},
"job": {
"created_at": 1646892733.656357,
"handle_at": 1646892733.93131,
"response_at": 1646892733.926631,
"protocol": "http",
"SDK": "\\Adapter\\XXXXX\\SDK\\XXXXSDK",
"api": "API.TEST",
"exec": {
"url": "http://xxxxx.com/xxxx/xxxx",
"method": "POST",
"header": [
"Content-Type: application/x-www-form-urlencoded",
"Content-length: 546"
],
"content": {
"goods_list":"",
"sid": "xxxxx",
"app_key": "xxxxxxxx",
"target_app_key": "xxxxxxx",
"timestamp": "2022-03-10 16:09:28",
"v": "2.0",
"format": "json",
"sign_method": "md5",
"method": "xxxxxxxxxxxxx",
"sign": "EC21D8E1285AF91992883C8229BC5B1E"
}
}
},
"response": {
"flag": "failure",
"code": 40,
"message": "Missing required arguments:goods_list.goods_no",
"request_id": "xxxxxxxxxxx"
}
}
}
],
"total": 1,
"condition": []
}
}
根据主键查询单个数据
● 请求地址:http://{{host}}/v2/open-api/business/{方案id}/find-one/{数据主键}?access_token={access_token}
● 请求方式:GET
● Headers:content-type:application/json
● Body:raw json
● 需要访问令牌:是
请求参数
请求参数 数据类型 是否必要 参数说明
数据主键 ?? 是 在集成平台中定义的数据id主键
激活源平台调度者
● 请求地址:http://{{host}}/v2/open-api/business/{方案id}/dispatch-source?access_token={access_token}
● 请求方式:GET
● Headers:content-type:application/json
● Body:raw json
● 需要访问令牌:是
激活目标平台调度者
● 请求地址:http://{{host}}/v2/open-api/business/{方案id}/dispatch-target?access_token={access_token}
● 请求方式:GET
● Headers:content-type:application/json
● Body:raw json
● 需要访问令牌:是
POSTMAN 示例
通过 POSTMAN 导入以下接口示例可以快速进行开发调试
{
"info": {
"_postman_id": "552f71ef-190d-4fca-b36c-427d3818bb7c",
"name": "轻易云数据集成中台-对外开放接口",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json",
"_exporter_id": "13049689"
},
"item": [
{
"name": "oauth",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"app_key\":\"41QALfYr8e5I\",\r\n \"app_secret\":\"4D0UkLIAVPbMEObXV40q\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": "http://www.ddhc.com/v2/oauth"
},
"response": []
},
{
"name": "查询集成方案数据列表",
"request": {
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"page\": 1,\r\n \"pageSize\": 2,\r\n \"begin_at\": 1,\r\n \"end_at\": 9999999999,\r\n \"condition\": {\r\n \"content.remark\": \"a\"\r\n },\r\n \"status\": \"0,1,2,3,4,5\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://www.ddhc.com/v2/open-api/business/eff3195a-2531-3d27-b4b5-b06c9fab737b/query?access_token=NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507",
"protocol": "http",
"host": [
"www",
"ddhc",
"com"
],
"path": [
"v2",
"open-api",
"business",
"eff3195a-2531-3d27-b4b5-b06c9fab737b",
"query"
],
"query": [
{
"key": "access_token",
"value": "NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507"
}
]
}
},
"response": []
},
{
"name": "根据主键找到一个数据ID",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"page\": 1,\r\n \"pageSize\": 2,\r\n \"begin_at\": 1,\r\n \"end_at\": 9999999999,\r\n \"condition\": {\r\n \"content.remark\": \"a\"\r\n },\r\n \"status\": \"0,1,2,3,4,5\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://www.ddhc.com/v2/open-api/business/eff3195a-2531-3d27-b4b5-b06c9fab737b/find-one/6?access_token=NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507",
"protocol": "http",
"host": [
"www",
"ddhc",
"com"
],
"path": [
"v2",
"open-api",
"business",
"eff3195a-2531-3d27-b4b5-b06c9fab737b",
"find-one",
"6"
],
"query": [
{
"key": "access_token",
"value": "NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507"
}
]
}
},
"response": []
},
{
"name": "调度源平台",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"page\": 1,\r\n \"pageSize\": 2,\r\n \"begin_at\": 1,\r\n \"end_at\": 9999999999,\r\n \"condition\": {\r\n \"content.remark\": \"a\"\r\n },\r\n \"status\": \"0,1,2,3,4,5\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://www.ddhc.com/v2/open-api/business/eff3195a-2531-3d27-b4b5-b06c9fab737b/dispatch-source?access_token=NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507",
"protocol": "http",
"host": [
"www",
"ddhc",
"com"
],
"path": [
"v2",
"open-api",
"business",
"eff3195a-2531-3d27-b4b5-b06c9fab737b",
"dispatch-source"
],
"query": [
{
"key": "access_token",
"value": "NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507"
}
]
}
},
"response": []
},
{
"name": "调度目标平台",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"page\": 1,\r\n \"pageSize\": 2,\r\n \"begin_at\": 1,\r\n \"end_at\": 9999999999,\r\n \"condition\": {\r\n \"content.remark\": \"a\"\r\n },\r\n \"status\": \"0,1,2,3,4,5\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://www.ddhc.com/v2/open-api/business/eff3195a-2531-3d27-b4b5-b06c9fab737b/dispatch-target?access_token=NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507",
"protocol": "http",
"host": [
"www",
"ddhc",
"com"
],
"path": [
"v2",
"open-api",
"business",
"eff3195a-2531-3d27-b4b5-b06c9fab737b",
"dispatch-target"
],
"query": [
{
"key": "access_token",
"value": "NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507"
}
]
}
},
"response": []
},
{
"name": "新增/修改数据",
"request": {
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"content\": [\r\n {\r\n \"id\":501,\r\n \"no\":\"ORDER2022-12\",\r\n \"main_params\":{\r\n \"limit\":123,\r\n \"offset\":33\r\n }\r\n },\r\n {\r\n \"id\":502,\r\n \"no\":\"ORDER2022-bv\",\r\n \"main_params\":{\r\n \"limit\":88888,\r\n \"offset\":33\r\n }\r\n }\r\n ]\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://www.ddhc.com/v2/open-api/business/eff3195a-2531-3d27-b4b5-b06c9fab737b/store?access_token=NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507",
"protocol": "http",
"host": [
"www",
"ddhc",
"com"
],
"path": [
"v2",
"open-api",
"business",
"eff3195a-2531-3d27-b4b5-b06c9fab737b",
"store"
],
"query": [
{
"key": "access_token",
"value": "NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507"
}
]
}
},
"response": []
},
{
"name": "根据ID批量删除数据",
"request": {
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"id\": []\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://www.ddhc.com/v2/open-api/business/eff3195a-2531-3d27-b4b5-b06c9fab737b/destory?access_token=NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507",
"protocol": "http",
"host": [
"www",
"ddhc",
"com"
],
"path": [
"v2",
"open-api",
"business",
"eff3195a-2531-3d27-b4b5-b06c9fab737b",
"destory"
],
"query": [
{
"key": "access_token",
"value": "NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507"
}
]
}
},
"response": []
},
{
"name": "根据ID重置数据状态",
"request": {
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"id\": [\"6\"]\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://www.ddhc.com/v2/open-api/business/eff3195a-2531-3d27-b4b5-b06c9fab737b/reset?access_token=NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507",
"protocol": "http",
"host": [
"www",
"ddhc",
"com"
],
"path": [
"v2",
"open-api",
"business",
"eff3195a-2531-3d27-b4b5-b06c9fab737b",
"reset"
],
"query": [
{
"key": "access_token",
"value": "NhZWHKUpDG313ba2782723dcabfe40cb7c04d7f507"
}
]
}
},
"response": []
}
]
}