Get the List of Spaces
This text provides an example of how to call Get the List of Spacesinterface.
Example: Get all the spaces you created or invited to enter
Suppose you have created a lot of spaces and are invited to enter many external spaces. You want to know the summary information of these spaces.
Your action steps below:
Get your API Token.(How to get it)
Open the terminal on your computer, execute the following code, and send query requests to the server:
- cURL
- Javascript SDK
- Python SDK
curl -X GET \
"https://aitable.ai/fusion/v1/spaces" \
-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',
});
// Get a list of spaces for the current user
const spaceListResp = await apitable.spaces.list()
if (spaceListResp.success) {
console.log(spaceListResp.data.spaces);
} else {
console.error(spaceListResp);
}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")
spaces = apitable.spaces.all()
for space in spaces:
print(space.json())The server returns the following JSON data, below the
"spaces"
is all created three spaces:For the meaning of each parameter in the response, please check the API Reference
{
"code": 200,
"success": true,
"data": {
"spaces": [
{
"id": "spcX9P2xUcKst",
"name": "Coco's Space",
"isAdmin": true
},
{
"id": "spcDWQSdso7fi",
"name": "Test Space",
"isAdmin": true
},
{
"id": "spc56JRl8TBlX",
"name": "Invited External Space",
}
]
},
"message": "SUCCESS"
}