Create Embedded Links
The Embedded Links are only available for the spaces on the paid Pro or higher plan in AITable Cloud as well as Enterprise self-hosted edition.
Node types that support creating embedded links are:
Example
Here is an example of calling API to create embedded links.
To create an embedded link for a specified datasheet in the space, follow the steps below:
Obtain your API token. (how to)
Obtain the spaceId. (how to)
Obtain the datasheetId. (how to)
Open your system terminal, copy and paste following code on it and make a request to AITable server (the example space ID here is
spcjXzqVrjaP3
, and the datasheetId isdstWUHwzTHd2YQaXEE
)- cURL
- Javascript SDK
- Python SDK
curl -X POST \
"https://aitable.ai/fusion/v1/spaces/spcjXzqVrjaP3/nodes/dstWUHwzTHd2YQaXEE/embedlinks" \
-H "Authorization: Bearer {Your API Token}" \
-H 'Content-Type: application/json' \
-d '{
"payload": {
"primarySideBar": {
"collapsed": false
},
"viewControl": {
"viewId": "viw4mnkqkaqdh",
"tabBar": true,
"nodeInfoBar": false,
"toolBar": {
"basicTools": false,
"widgetBtn": false,
"apiBtn": false,
"formBtn": false,
"historyBtn": false,
"robotBtn": false,
"addWidgetBtn": false,
"fullScreenBtn": false,
"formSettingBtn": false
},
"collapsed": false,
"collaboratorStatusBar": true
},
"bannerLogo": true,
"permissionType": "readOnly"
},
"theme": "light"
}'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 embedLinkCreateRo = {
"payload": {
"primarySideBar": { "collapsed": false },
"viewControl": {
"viewId": 'viw4mnkqkaqdh',
"tabBar": false,
"nodeInfoBar": false,
"toolBar": {
"basicTools": false,
"widgetBtn": false,
"apiBtn": false,
"formBtn": false,
"historyBtn": false,
"robotBtn": false,
"addWidgetBtn": false,
"fullScreenBtn": false,
"formSettingBtn": false
},
"collapsed": false,
"collaboratorStatusBar": true
},
"bannerLogo": true,
"permissionType": 'readOnly'
},
"theme": EmbedLinkTheme.Light
};
try {
const res = await apitable.space('spcjXzqVrjaP3').datasheet('dstWUHwzTHd2YQaXEE').createEmbedLink(embedLinkCreateRo);
if (res.success) {
embedId = res.data?.linkId || '';
}
} catch (error) {
// TODO: handle error
}Note: You need to download and initialize the Python SDK first, and then execute the following command.
from apitable import Apitable
from apitable.types import EmbedLinkThemeEnum, EmbedLinkPermissionType
apitable = Apitable("Your API Token")
try:
newEmbedLink = (
apitable.space("spcjXzqVrjaP3")
.datasheet("dstWUHwzTHd2YQaXEE")
.create_embed_link(
{
"payload": {
"primarySideBar": {"collapsed": False},
"viewControl": {
"viewId": "viwBBc0PMN3WB",
"tabBar": False,
"toolBar": {
"basicTools": False,
"widgetBtn": False,
"apiBtn": False,
"formBtn": False,
"historyBtn": False,
"robotBtn": False,
"addWidgetBtn": False,
"fullScreenBtn": False,
"formSettingBtn": False
},
"collapsed": False,
"collaboratorStatusBar": True,
"nodeInfoBar": False,
},
"bannerLogo": True,
"permissionType": EmbedLinkPermissionType.READ_ONLY,
},
"theme": EmbedLinkThemeEnum.Light,
}
)
)
print(newEmbedLink.linkId)
except Exception:
# handle error
passThe server will return the following JSON object, and the information of the embedded link will be displayed in
data
property:{
"code": 200,
"success": true,
"data": {
"linkId": "embb90a52cfc02a4f83",
"url": "https://aitable.ai/embed/embb90a52cfc02a4f83",
"payload": {
"primarySideBar": {
"collapsed": false
},
"viewControl": {
"viewId": "viw4mnkqkaqdh",
"tabBar": false,
"toolBar": {
"basicTools": false,
"widgetBtn": false,
"apiBtn": false,
"formBtn": false,
"historyBtn": false,
"robotBtn": false,
"addWidgetBtn": false,
"fullScreenBtn": false,
"formSettingBtn": false
},
"collapsed": false,
"collaboratorStatusBar": true,
"nodeInfoBar": false
},
"bannerLogo": true,
"permissionType": "readOnly"
},
"theme": "light"
},
"message": "SUCCESS"
}tipFor the meaning of each parameter in the response result above, please check the API Reference.