https://github.com/volcengine/datafinder-sdk-openapi-js
https://github.com/volcengine/datafinder-sdk-openapi-js
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/volcengine/datafinder-sdk-openapi-js
- Owner: volcengine
- License: other
- Created: 2022-03-21T06:14:08.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-01T04:09:06.000Z (about 4 years ago)
- Last Synced: 2025-01-07T15:21:17.596Z (over 1 year ago)
- Language: JavaScript
- Size: 20.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# openapi 使用说明
### 1. 语法
common js 语法
### 2、样例
* 调用服务
query.js
```js
const oepnapisdk = require("@/datafinder/openapisdk");
const RangersClient = oepnapisdk.RangersClient;
function testQuery() {
ak = "xxxx"
sk = "xxxx"
rc = new RangersClient(ak, sk)
dsl = {
"version": 3,
"app_ids": [0],
"use_app_cloud_id": true,
"periods": [
{
"granularity": "day",
"type": "last",
"last": {
"amount": 5,
"unit": "day"
},
"timezone": "Asia/Shanghai"
}
],
"contents": [
{
"query_type": "event",
"profile_groups": [],
"profile_filters": [],
"queries": [
[
{
"event_type": "origin",
"show_name": "活跃用户数",
"event_name": "app_launch",
"groups": [],
"filters": [],
"show_label": "active_user",
"event_indicator": "event_users"
}
]
],
"option": {
"skip_cache": false
}
}
]
}
resp = rc.dataFinder("/openapi/v1/analysis", { body: JSON.stringify(dsl) })
.then(res => res.json())
.then(response => {
console.log("response: " + JSON.stringify(response));
if (200 !== response['code']) {
throw "result is not ok, code: " + response['code'] + ", message: " + response['message'];
}
result = response['data']
result.forEach(item => {
if ('SUCCESS' !== item['result_status']) {
throw "result item is not ok, status: " + item['result_status'] + ", error message: " + item['error_message'];
}
})
console.log('success.')
})
.catch(error => console.error('error:', error));
}
```
* 运行测试用例:
```shell
node query.js
```