@boltapp/bolt-api
v0.0.15
Published
API layer for Bolt applications. Defines operation interfaces and creates callable APIs or REST handlers.
Downloads
1,415
Readme
@boltapp/bolt-api
API layer for Bolt applications. Defines operation interfaces and creates callable APIs or REST handlers.
Installation
pnpm add @boltapp/bolt-apiQuick Start
Next.js (Auto-generated)
Run bolt sync to generate API routes:
// .bolt/api/bolt-handler.ts
import { createNextBoltHandlers } from "@boltapp/bolt-api";
import { bolt } from "../bolt";
export const { GET, POST, PUT, PATCH, DELETE } = createNextBoltHandlers(bolt);Custom Handler
import { createBoltApiHandler } from "@boltapp/bolt-api";
import { bolt } from "./bolt";
const app = createBoltApiHandler(bolt, "/api/bolt");Direct API Usage
import { createAppPublicApi } from "@boltapp/bolt-api/app-public";
import { createDataTableApi } from "@boltapp/bolt-api/data-table";
import { createDataStoreApi } from "@boltapp/bolt-api/data-store";
const publicApi = createAppPublicApi(bolt);
const tableApi = createDataTableApi(bolt);
const storeApi = createDataStoreApi(bolt);
// App operations
const app = await publicApi.app.get();
const tables = await publicApi.project.tables.list();
// Table operations
const table = await tableApi.get("table_123");
await tableApi.sendBatch({ viewId, operations: [...] });
// Data store operations
const store = await storeApi.get("my_store");
await storeApi.setItem("my_store", "key", { value: 123 });API Bundles
app-public
For Who: External developers building Bolt-powered applications. This is the primary API surface for apps that use Bolt for data storage. Safe for client-side use.
Authentication:
- Client apps: None (local SQLite)
- Cloud apps:
X-Bolt-App-Id,X-Bolt-Org-Id,X-Bolt-Project-Secretheaders
Operations: App info, data stores, files, project info, project tables list/create, project data access.
data-table
For Who: Bolt DevTools and admin interfaces needing full table management. Used for batch updates, cell editing, and table operations.
Authentication:
- Client apps: None (local SQLite)
- Cloud apps:
X-Bolt-App-Id,X-Bolt-Org-Id,X-Bolt-Project-Secretheaders
Operations: Get table, delete table, send batch, get/set cells.
data-store
For Who: Bolt DevTools and developers managing key-value stores for app config, feature flags, and non-tabular data.
Authentication:
- Client apps: None (local SQLite)
- Cloud apps:
X-Bolt-App-Id,X-Bolt-Org-Id,X-Bolt-Project-Secretheaders
Operations: Get store, delete store, get/set/update/delete items.
app-admin
For Who: Internal dashboard and admin applications. Used by the Bolt dashboard for full app management including app settings, table views, and all CRUD operations.
Authentication:
- Internal use only (not exposed via REST endpoints)
- Uses session-based authentication (via
requireOrgContext) - No project secret required — secrets are for external/public API access
- Create instances with
createCloudAdminInstanceinstead ofcreateCloudBoltInstance
Operations: Full app CRUD, table views management, all data operations.
Usage (Dashboard):
import { getAppAdminApi } from "@/lib/bolt-admin";
export async function listAppTables(appId: string) {
const { api } = await getAppAdminApi(appId);
return api.tables.list();
}Exports
// Handlers
import { createBoltApiHandler, createNextBoltHandlers } from "@boltapp/bolt-api";
// App Public
import { createAppPublicApi, createAppPublicRestHandler } from "@boltapp/bolt-api/app-public";
// App Admin (for dashboard/admin apps)
import { createAppAdminApi } from "@boltapp/bolt-api/app-admin";
// Data Table
import { createDataTableApi, createDataTableRestHandler } from "@boltapp/bolt-api/data-table";
// Data Store
import { createDataStoreApi, createDataStoreRestHandler } from "@boltapp/bolt-api/data-store";REST Endpoints
When using createBoltApiHandler with base path /api/bolt:
App Public
GET /api/bolt/app- Get appGET /api/bolt/app/info- Get app infoPATCH /api/bolt/app- Update appGET /api/bolt/app/data-stores- List data storesPOST /api/bolt/app/data-stores- Create data storeGET /api/bolt/project/info- Get project infoGET /api/bolt/project/tables- List tablesPOST /api/bolt/project/tables- Create tableGET /api/bolt/project/data/tables/:tableId- Get simplified table rowsGET /api/bolt/project/data/items/:itemId- Get item value by itemId
Data Table
GET /api/bolt/project/tables/id/:tableId- Get tableGET /api/bolt/project/tables/view/:viewId- Get table by viewDELETE /api/bolt/project/tables/id/:tableId- Delete tablePOST /api/bolt/project/tables/id/:tableId/batch- Send batch operationsGET /api/bolt/project/tables/id/:tableId/cells/:rowId/:columnId- Get cellPUT /api/bolt/project/tables/id/:tableId/cells/:rowId/:columnId- Set cellGET /api/bolt/project/tables/views/:viewId- Get viewGET /api/bolt/project/tables/id/:tableId/views- List viewsPOST /api/bolt/project/tables/id/:tableId/views- Create viewPATCH /api/bolt/project/tables/views/:viewId- Update viewDELETE /api/bolt/project/tables/views/:viewId- Delete viewPUT /api/bolt/project/tables/id/:tableId/views/reorder- Reorder views
Data Store
GET /api/bolt/app/data-stores/name/:storeName- Get storeDELETE /api/bolt/app/data-stores/id/:storeId- Delete storeGET /api/bolt/app/data-stores/name/:storeName/items/:key- Get itemPUT /api/bolt/app/data-stores/name/:storeName/items/:key- Set itemPATCH /api/bolt/app/data-stores/name/:storeName/items/:key- Update itemDELETE /api/bolt/app/data-stores/name/:storeName/items/:key- Delete item
License
Licensed under a custom Boltapp public-use license. Free use is allowed in unmodified form. Redistribution and modification are not allowed. See LICENSE.md.
