Get Views
This text provides an example of how to call Get views interface.
Example: Get all views of a specified datasheet
Suppose you have a channel sales inventory summary datasheet and you want to get information about all the views of this datasheet.
Your action steps below:
Get your API Token.(How to get it)
Get the ID of the datasheet.(How to get it)
Open the terminal on your computer, execute the following code and send the query request to the server (assuming datasheetId is
dst0vPx2577RdMN9MC
):- cURL
- Javascript SDK
- Python SDK
curl -X GET \
"https://aitable.ai/fusion/v1/datasheets/dst0vPx2577RdMN9MC/views" \
-H "Authorization: Bearer {Your API Token}"Note: Need to Download and initialize Javascript SDK first, and then execute the following command.
import { APITable } from 'apitable';
const apitable = new APITable({
token: 'Your API Token',
});
const datasheet = apitable.datasheet("dst0vPx2577RdMN9MC");
const viewsResp = await datasheet.views.list()
if (viewsResp.success) {
console.log(viewsResp.data.views);
} else {
console.error(viewsResp);
}Note: You need to download and initialize the Python SDK first, and then execute the following command.
from apitable import Apitable
apitable = Apitable("Your API Token")
dst = apitable.datasheet("dst0vPx2577RdMN9MC")
views = dst.views.all()
for view in views:
print(view.json())The server returns the following JSON data, below the
"views"
is all data in this view:For the meaning of each parameter in the response, please check the API Reference
{
"code": 200,
"success": true,
"data": {
"views": [
{
"id": "viwBBD0FJmGgl",
"name": "Grid view",
"type": "Grid"
},
{
"id": "viwHikMoyvm3U",
"name": "Gallery",
"type": "Gallery"
},
{
"id": "viwZbTXzYeLOm",
"name": "Brand Grouping",
"type": "Grid"
},
{
"id": "viwi88msbLv50",
"name": "Kanban",
"type": "Kanban"
},
{
"id": "viwWwIQcQKdKw",
"name": "Gantt",
"type": "Gantt"
}
]
},
"message": "SUCCESS"
}