Skip to content
Browse documentation
Connect to data

Lark Base

Create an app, grant document access, and load data from Lark Base with an illustrated guide.

Create a Lark app, grant access to your Base, and load its data into AVA. Once connected, query it with the CLI or Node.js SDK, or use the Agent Skill to analyze the data and generate charts.

Before you start

  • A Lark account that can create an enterprise custom app, and permission to manage the target Base. Ask your administrator or document owner to complete any required approvals.
  • Node.js 22.13.0 or later. The CLI currently supports macOS / Linux; see the CLI guide for installation.
  • The browser URL of the target table, usually containing /base/ or /wiki/.

AVA reads as the app and copies the data into read-only DuckDB tables in Node.js: a URL that names a table loads it as data, and a URL without a table loads every table of the Base under its own name. Loading, inspecting the schema, and running SQL do not require a model API key. Configure a model for AVA's natural-language analysis and visualization as described in Model configuration.

Click any screenshot to view it at full size.

1. Create an app and get credentials

  1. Open the developer console on the Lark Open Platform and create an enterprise custom app, or reuse an existing one.
  2. Enter a name and description, such as “AVA analytics”.
  3. Find App ID and App Secret on the app's Credentials & Basic Info page for the binding step below.

App ID identifies the Open Platform app; App Secret authenticates it to obtain a tenant_access_token. These are different from the App Token in a Base URL. AVA obtains the access token automatically, so you do not need to copy one manually.

Create Custom App button in the Lark Developer Console
Select Create Custom App to begin.
Credentials & Basic Info entry in the Lark app sidebar
Open Credentials & Basic Info to find your app credentials.

2. Enable permissions and grant document access

Open Platform: allow the app to call read APIs

In Permissions & Scopes, search for Base and request permissions to read tables, fields, and records. Follow the permission requirements in Lark's API documentation. AVA calls the following read endpoints:

Permissions & Scopes page listing Lark Base scopes
Use Permissions & Scopes to find the read scopes required by the endpoints below. The Create Version button opens the release form.
EndpointPurposeWhen required
GET /open-apis/bitable/v1/apps/{app_token}Read the time zone of the Base, used for datesEvery load
GET /open-apis/bitable/v1/apps/{app_token}/tablesList the tablesEvery load
GET /open-apis/bitable/v1/apps/{app_token}/tables/{table_id}/fieldsRead field names and typesEvery load, also for tables that link fields point to
POST /open-apis/bitable/v1/apps/{app_token}/tables/{table_id}/records/searchRead recordsEvery load; linked tables outside the selection are read with their primary field only
GET /open-apis/wiki/v2/spaces/get_nodeResolve a Wiki node to its BaseFor /wiki/ URLs; also request Wiki read permissions

See the Lark Base API documentation. Create and publish a version under Version Management & Release after requesting permissions. Wait for administrator approval when required, and confirm the permissions have taken effect.

Base: allow the app to read the target document

  1. In the target Base, open the top-right ··· menu and choose More → Add Applications. The entry may also appear as Add Document App.
  2. Search for and add the app you created, granting read access. If the entry or app is unavailable, ask the document owner to check document permissions, app publication, and availability.
  3. If advanced permissions are enabled, confirm the app can read the tables, records, and fields you want to analyze.
  4. For a /wiki/ URL, also grant the app access to the corresponding Wiki space through its access settings. Base permissions alone do not allow Wiki node resolution.
Lark Base menu with More and Add Applications highlighted
Open More → Add Applications in the target Base.
Lark Applications dialog showing an added app and its access dropdown
Use the dropdown next to the added app to check its access. The example shows Can manage. Choose read access for AVA.

Select the table you want to analyze, then copy the full URL from the browser address bar, keeping the table parameter:

text
https://my.larksuite.com/base/APP_TOKEN?table=TABLE_ID&view=VIEW_ID
https://my.larksuite.com/wiki/NODE_TOKEN?table=TABLE_ID&view=VIEW_ID
URL valueConfigurationMeaning
APP_TOKEN after /base/appTokenBase identifier, distinct from App ID
NODE_TOKEN after /wiki/Keep it in urlWiki node identifier; AVA resolves the actual App Token. Do not use the node token as appToken.
table=TABLE_IDtableIdTarget table identifier
view=VIEW_IDviewId (optional)Ignored in a URL; set viewId in a configuration to load only that view

Without table, AVA loads every table of the Base under its own name. Every table gets a record_id primary key. Link fields show the primary field of the linked records; when a link holds at most one record per row, it also gets a <field>_record_id column that the schema declares as a relationship to the linked table, so you can join tables. Lark /docx/, /sheets/, and Wiki nodes hosting other document types are not supported by this source.

Always pass the full Lark URL in url. AVA uses its larksuite.com domain to select the Lark API. When you supply only appToken and tableId, AVA defaults to the Feishu China API.

4. Bind credentials and load data

Option 1: first-time terminal binding

Install the CLI and run the following in an interactive terminal, replacing the URL with your actual table URL:

bash
npm install -g @antv/ava
ava source "https://my.larksuite.com/base/APP_TOKEN?table=TABLE_ID"

If credentials are not configured, AVA prompts for App ID and App Secret. The secret is not echoed. Successful binding saves credentials to the current user's ~/.ava/feishu.json for later loads. Binding only verifies that the app can obtain a token; document access is checked during the subsequent load.

text
App ID: cli_YOUR_APP_ID
App Secret:

Option 2: environment variables

Set these variables in your macOS / Linux shell. For automation, use the runtime's secret configuration.

bash
export AVA_FEISHU_APP_ID='YOUR_APP_ID'
export AVA_FEISHU_APP_SECRET='YOUR_APP_SECRET'
ava source "https://my.larksuite.com/base/APP_TOKEN?table=TABLE_ID"

Option 3: source configuration file

Save the following as lark-source.json. This file specifies the source only; credentials can still come from environment variables or saved binding information.

json
{
  "type": "feishu-bitable",
  "options": {
    "url": "https://my.larksuite.com/base/APP_TOKEN?table=TABLE_ID"
  }
}
bash
ava source @lark-source.json
Configuration fieldRequiredDescription
urlYes for LarkFull Base or Wiki URL on larksuite.com
appTokenNoBase App Token, if supplied alongside the URL
tableIdNoTable to load as data. Omit it, and table in the URL, to load the whole Base.
viewIdNoLoad only the records visible in this view; requires a table
appId / appSecretOne credential is required; the CLI can resolve it elsewhereOpen Platform app credentials
accessTokenOne credential is requiredTenant or user access token obtained by your application
timeZoneNoIANA time zone for dates; defaults to the time zone of the Base

When both url and appToken / tableId are supplied, they must identify the same table. viewId requires a table, and timeZone (an IANA name such as Asia/Shanghai) overrides the time zone of the Base for dates.

CLI credential priority is configuration (appId + appSecret, or accessToken) → AVA_FEISHU_APP_ID / AVA_FEISHU_APP_SECRET → ~/.ava/feishu.json → interactive terminal binding. A configuration may contain only one kind of credential. A partial pair in either of the first two sources causes an error; credentials from different sources are not combined. Piped input, redirection, and other non-interactive environments do not prompt for binding, so configure credentials beforehand.

Keep App Secret and the saved binding file out of Git and logs. To change a saved app, update the complete credential pair in the binding file, or override it with higher-priority environment variables.

People, attachments, links, locations, and groups are read as text, usually with multiple values separated by commas. Formulas and lookup fields are read according to the type of value they return.

5. Verify the data and start analysis

A successful load returns a dataset ID. Replace YOUR_DATASET_ID with that actual value to inspect the schema, sample rows, and record count:

bash
ava schema YOUR_DATASET_ID
ava query YOUR_DATASET_ID --dsl 'SELECT * FROM data LIMIT 5'
ava query YOUR_DATASET_ID --dsl 'SELECT COUNT(*) AS row_count FROM data'

Check the table names (data for one table, the Base table names for a whole Base), field names, and read scope. The count should match the target table accessible to the app. Run ava dispose YOUR_DATASET_ID when finished. After changes in Base, run ava source again and use the new ID; existing sessions do not continuously synchronize remote changes.

Column types come from the field metadata. Dates are read in the time zone of the Base, as shown in Lark: date fields become DATE; date-time fields and created or modified times become TIMESTAMP. Unchecked checkboxes are false. Multi-select, people, groups, attachments, links, and lookups become lists (VARCHAR[], queried with list_contains or UNNEST) only when some record holds several values; otherwise they are plain columns. Attachments expose file names without downloading files. Formula and lookup fields take the type of their result. Workflow and button fields are skipped; an empty table preserves supported field definitions.

After installing the AVA Skill, you can ask your agent:

text
Use AVA Skill to analyze this Lark Base: <replace with the full URL>.
Credentials are configured locally. Inspect the schema and verify the record count,
then count records by department using the actual fields.
Provide the query, results, and a chart. Make any time filters explicit in the query.

Use the Node.js SDK

Pass credentials explicitly to the SDK; it does not automatically read the CLI binding file or environment variables. This example reads environment variables in application code and runs queries without calling a model:

javascript
import { AVA } from '@antv/ava';
 
const ava = new AVA({
  llm: { model: 'gpt-4o-mini' },
  engine: { type: 'duckdb' },
});
 
try {
  await ava.source({
    type: 'feishu-bitable',
    options: {
      url: 'https://my.larksuite.com/base/APP_TOKEN?table=TABLE_ID',
      appId: process.env.AVA_FEISHU_APP_ID,
      appSecret: process.env.AVA_FEISHU_APP_SECRET,
    },
  });
  console.log(await ava.schema());
  console.log(await ava.query('SELECT COUNT(*) AS row_count FROM data'));
} finally {
  await ava.dispose();
}

Troubleshooting

SymptomCheck and resolution
App binding failsCheck that App ID and App Secret belong to the same enterprise custom app, are copied in full, and belong to the Lark tenant hosting your Base. The error preserves the platform's code and message.
Binding succeeds but loading reports insufficient permissionsConfirm read API permissions are published and effective, and the same app is added to the target document. Your own access does not grant app access.
/base/ works but /wiki/ failsCheck Wiki read API permissions, space access, and whether the node hosts a Base.
Error contains reported … records but returned …The table changed while it was being read. Load it again.
Error contains does not matchRemove redundant identifiers or ensure url, appToken, and tableId identify the same table.
Missing credentials in a non-interactive environmentConfigure paired environment variables, a complete source configuration, or a saved binding file beforehand.
~/.ava/feishu.json is not valid JSONRepair the file to valid JSON containing appId and appSecret, or override it with environment variables.
More records than the view shows, or remote changes are missingThe view of a URL is ignored; filter in SQL or set viewId. Reload the source to read remote updates.
Network error or non-JSON responseCheck connectivity and proxy settings for open.larksuite.com, and inspect the original failing request.

See the CLI guide for complete commands and Data sources for other connectors.

Screenshot references include LadiPage’s Lark Base setup guide and the Lark AnyCross Base archiving tutorial.