Introduction #
API datasets allow SmartChart to directly send HTTP requests to external interfaces and obtain JSON data as dataset content. Write a dataset = {...} object in the dataset editor to describe the request method, URL, and parameters. Supports GET/POST and parameter linkage.
API Requirements #
The interface must return JSON format
Data Source Configuration #
You can choose any data connection
Usage #
Simple GET and POST examples:
//GET method:
dataset= {
"url":"https://www.smartchart.cn/smartdata/api/?i=loaddataset1&j=1"
}
//POST method:
dataset= {
"url":"https://www.smartchart.cn/smartdata/api",
"method":"POST",
"data":{"i":"loaddataset1", "j":"1"}
}
Pass parameters for linkage:
dataset= {
"url":"https://www.smartchart.cn/smartdata/api",
"method":"POST",
"data":{"i":"loaddataset1", "j":"/*$param_name*/"}
}
Add headers for authentication:
dataset= {
"url":"https://www.smartchart.cn/smartdata/api",
"method":"GET",
"headers":{"Cookie":"xxxxxxx"}
}
API Dataset Configuration Fields #
| Field | Required | Description |
|---|---|---|
url |
Yes | Interface URL |
method |
No | GET (default) or POST |
data |
No | POST request body, dictionary format |
headers |
No | Request headers, e.g., Cookie, Authorization |
/*$param_name*/ |
No | Embed linkage parameters in data or url. When parameter is not passed, the entire segment is ignored |
Complete example: POST request with parameter linkage
dataset = {
"url": "https://api.example.com/data",
"method": "POST",
"data": {
"type": "sales",
"region": "/*$region*/"
},
"headers": {
"Authorization": "Bearer your_token"
}
}