Quick Start
This paper describes how to quickly start viewing the AITable API in 5 minutes.
Step 1: Get API Token
API Token is the user authentication token.When sending API requests to AITable server, you must take Authorization: Bearer {Your API Token}
at the head of the request to facilitate server authentication.
When authenticated successfully, the API request will have the same permissions as the user has to operate on the APITAble interface, that is, what data the user can do on the interface, and what data can be used in the request.
Get API Token as follows::
Sign in to AITable and tap the profile of the lower left corner, enter the User Center and go to the Developer Configuration.
Click "+" to generate an API Token.Note: You need to bind your email when you generate it for the first time.
Copy API Token.
Note:
- Please secure your API Token, if API Token leaks, others may tamper with data in your datasheet.
- If the API Token is leaked, you can regenerate the Token in the Developer Configuration screen to ensure data security.
Step 2: Calling the API interface to implement data additions and deletions
Select the programming language you are familiar with (e.g. Javascript) and make sure you need to call the AITable API interface you can choose either of the following ways to send requests to the API server.
Method 1: Send HTTPS request directly
Example HTTPS request in some common languages using the Access API interface:
Note: Before executing the following code, you need to replace the
{datasheetid}
and{your API Token}
to the real datasheetId and API token.
- cURL
- JavaScript
- Python
curl "https://aitable.ai/fusion/v1/datasheets/{datasheetId}/records" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {Your API Token}"
// Method 1: Fetch
const URL = 'https://aitable.ai/fusion/v1/datasheets/{datasheetId}/records'
const res = await fetch(URL, {
method: 'GET',
headers: new Headers({
'Content-Type': 'application/json',
'Authorization': 'Bearer {Your API Token}'
})
})
//Method 2: Axios
const URL = 'https://aitable.ai/fusion/v1/datasheets/{datasheetId}/records'
const res = await axios.get(URL, {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {Your API Token}'
}
});
import requests
request_url = 'https://aitable.ai/fusion/v1/datasheets/{datasheetId}/records'
headers = {"Authorization": "Bearer {Your API Token}","Content-Type":"application/json"}
response = requests.get(request_url, headers=headers)
result = response.json()
You can also send HTTPS requests by selecting any other language or library.
Method 2: Use officially provided SDK
The SDK (Sofware Development Kit, Software Development Toolkit) provides a cover for network requests and authentications, handles details on many API requests and helps you quickly start to experience AITable API. AITable SDK is officially provided on GitHub. Before using SDK, you need to execute the following commands on the terminal of the computer to install and initialize the SDK
- Javascript SDK
- Python SDK
Install the Javascript SDK by either of the following methods.
- npm
- yarn
# You need to install npm in advance
npm install apitable@latest# You need to install yarn in advance
yarn add apitable@latest
Initialize the Javascript SDK.
import { APITable } from "apitable";
const apitable = new APITable({ token: "_Your_API_Token_"});When instantiating the SDK client you have the option to configure the following global parameters.
Options Type Default value Description token string Required, representing the incoming API Token fieldKey string name The key used to query and return fields.By default use name
(field name).\n When specified asid
, fieldId will be used as the query and return method (usingid
can avoid code failure caused by modifying the field name)requestTimeout number 60000 Request expiration time, milliseconds, default value is 6000000 (i. e. 10 seconds) host string https://aitable.ai/fusion/v1
Destination server adapter any If it needs to be used in the WeChat Miniprogram, a request adapter needs to be added, see Using Vika JS SDK in the WeChat Miniprogram
Install Python SDK.
# Python version needs to be v3.6 or above
# Need to install pip in advance
pip install --upgrade apitableInitialize the Python SDK.
from apitable import Apitable
apitable = Apitable("_Your_API_Token_")
Once the request is determined, you can write the code, calling the corresponding APItable API interface.