OpenAPI Quick Start
Welcome to the Bika.ai Quick Start Guide! This document provides a series of examples to help you get started with the Bika.ai API and SDK. Each section contains code snippets for common operations, including fetching data, creating records, updating records, deleting records, and using automation.
Prerequisites
- Node.js installed on your machine.
- Bika.ai API Token: Sign up on Bika.ai and get your API token from your user settings.
Installation
First, install the Bika.ai SDK using npm:
npm install bika.ai
Example 1: Fetch Data
This example demonstrates how to fetch spaces, nodes, and records.
javascript
复制
import { Bika } from 'bika.ai';
const bika = new Bika({
apiKey: '__PASTE_YOUR_API_TOKEN_FROM_USER_SETTING__',
baseURL: 'https://bika.ai/api/openapi/bika',
});
async function fetchData() {
try {
const spaces = await bika.spaces.list();
const space = spaces[0];
const nodes = await space.nodes.list();
const node = nodes[0];
const database = await node.asDatabase();
const records = await database.records.list();
console.log('Records:', records);
} catch (error) {
console.error('Error fetching data:', error);
}
}
fetchData();
Example 2: Create a New Record
Use this example to create a new record in your database.
javascript
复制
async function createRecord() {
try {
const spaces = await bika.spaces.list();
const space = spaces[0];
const nodes = await space.nodes.list();
const node = nodes[0];
const database = await node.asDatabase();
const newRecord = await database.records.create({
fields: {
Name: '新记录',
Description: '这是一个新创建的记录',
},
});
console.log('New Record Created:', newRecord);
} catch (error) {
console.error('Error creating record:', error);
}
}
createRecord();
Example 3: Update a Record
This example updates an existing record.
javascript
复制
async function updateRecord(recordId) {
try {
const spaces = await bika.spaces.list();
const space = spaces[0];
const nodes = await space.nodes.list();
const node = nodes[0];
const database = await node.asDatabase();
const updatedRecord = await database.records.update(recordId, {
fields: {
Description: '更新后的描述',
},
});
console.log('Record Updated:', updatedRecord);
} catch (error) {
console.error('Error updating record:', error);
}
}
updateRecord('__REPLACE_WITH_RECORD_ID__');
Example 4: Delete a Record
Use this example to delete a specific record.
javascript
复制
async function deleteRecord(recordId) {
try {
const spaces = await bika.spaces.list();
const space = spaces[0];
const nodes = await space.nodes.list();
const node = nodes[0];
const database = await node.asDatabase();
await database.records.delete(recordId);
console.log('Record Deleted:', recordId);
} catch (error) {
console.error('Error deleting record:', error);
}
}
deleteRecord('__REPLACE_WITH_RECORD_ID__');
Example 5: List Automation Triggers
This example shows how to list automation triggers.
javascript
复制
async function listTriggers() {
try {
const spaces = await bika.spaces.list();
const space = spaces[0];
const nodes = await space.nodes.list();
const node = nodes[0];
const automation = await node.asAutomation();
const triggers = await automation.triggers.list();
console.log('Triggers:', triggers);
} catch (error) {
console.error('Error listing triggers:', error);
}
}
listTriggers();
Example 6: Register an Outgoing Webhook
This example demonstrates how to register an outgoing webhook.
javascript
复制
async function registerWebhook() {
try {
const spaces = await bika.spaces.list();
const space = spaces[0];
const outgoingWebhook = await space.outgoingWebhooks.create({
eventType: 'ON_RECORD_CREATED',
name: '记录创建Webhook',
description: '当记录被创建时触发',
callbackURL: 'https://your-custom-callback-url.com',
});
console.log('Webhook Registered:', outgoingWebhook);
} catch (error) {
console.error('Error registering webhook:', error);
}
}
registerWebhook();
Conclusion
This Quick Start Guide provides basic examples to help you interact with the Bika.ai API and SDK effectively. You can modify and expand these examples as needed for your specific use cases. For more detailed information, refer to the Bika.ai API Documentation. Happy coding!
Quick Start
Let's quick start with curl
example:
curl -X GET "https://bika.ai/api/openapi/bika/v1/system/meta" -H "Authorization: Bearer {YOUR_ACCESS_TOKEN}"
# Response: {"success":true,"code":200,"message":"SUCCESS","data":{"version":"1.0.0-release.0","appEnv":"PRODUCTION","hostname":"https://bika.ai","headers":{"X-Forwarded-For":"35.96.5.64","User-Agent":"curl/8.4.0"}}}%
Bika.ai's offical JavaScript use beautiful Object-Oriented Programming (OOP) style for your better use.
npm install bika.ai
# or
yarn add bika.ai
pnpm add bika.ai
Examples to use Bika.ai offical Node.js SDK. (TypeScript example)
Get Spaces:
import { Bika } from 'bika.ai';
const bika = new Bika({
apiKey: '__PASTE_YOUR_API_TOKEN_FROM_USER_SETTING__',
baseURL: 'https://bika.ai/api/openapi/bika',
});
// firstly, fetch your spaces
const spaces = await bika.spaces.list();
// now we use your first space as our operations
const space = spaces[0];
Find Node Resources (Database, Automation, Folder, Documents, etc.):
// find node resources
const nodes = await space.nodes.list();
// get one node resource
const node = nodes[0];
const database = await node.asDatabase();
const automation = await node.asAutomation();
Here’s an example of Create, Read, Update, and Delete (CRUD) operations for databases.
Given that Bika.ai's database can handle billions of rows, you can use Bika.ai databases as a fully functional production database, such as for an order table, user table, and more.
// notice, use `asXXX`,depends on your node resource type, includes database, automation, folder, and so-on
const database = await node.asDatabase();
const records = await database.records.list();
const views = await database.views.list();
CRUD Automations:
const automation = await node.asAutomation();
const triggers = await automation.triggers.list();
const actions = await automation.actions.list();
Here are examples of registering global-scope or space-scope outgoing webhooks (Server Events in Bika.ai).
You can utilize outgoing webhooks to send HTTP POST requests to your callback URL whenever a specific event takes place in Bika.ai.
Use cases include contact synchronization, data synchronization, custom notifications, plugins, and more.
// Outoging Webhooks
// Register a Bika.ai server event, and send a HTTP POST request to your callback URL
const outgoingWebhook = await space.outgoingWebhooks.create({
eventType: 'ON_RECORD_CREATED',
name: 'Test Outgoing Webhook',
description: 'Test Outgoing Webhook Desc',
callbackURL: 'https://your-custom-callback-url.com',
});
const outgoingWebhooks = await space.outgoingWebhooks.list();
const delteOutgoingWebhook = await space.outgoingWebhooks.delete({id: outgoingWebhook.id});
Here are examples of embedding Bika.ai's UI into your own application.
If you want to incorporate Bika.ai's robust UI for databases, documents, and more, you can utilize the embed link API.
Generate an embed link to obtain a URL, and then use an <iframe>
in your application.
// Embed Links
// You can embed Bika.ai's UI into your own application
const embedLink = await space.embedLink.create({
objectType: 'NODE_RESOURCE',
objectId: '__NODE_RESOURCE_ID_YOU_WANT_TO_EMBED__',
});
const embedLinks = await space.embedLink.list();
const deleteEmbedLink = await space.embedLink.delete({id: embedLink.id});
// ...
Please checkout the Bika.ai API Reference for more API details.

Recommend Reading
- Unleash the Power of Automated Tweet Campaigns with Bika.ai
- Bika.ai vs Airtable: To Team collaboration communication
- Stock Trend News Roundup: Airtable Alternative to Follow market dynamics
- Vika OKR: A Quality Airtable Alternative about Automation
- 7-Day Automated Email Marketing: Airtable Alternative to update feature introduction
Recommend AI Automation Templates





