API & SDK
Design Philosophy
Section titled “Design Philosophy”Eidos doesn’t provide traditional REST APIs. Instead, it exposes Eidos’s core capabilities through a unified SDK interface. This means that official features, extension development, and API calls all use the same interfaces and methods.
Unified Calling Approach
Section titled “Unified Calling Approach”Eidos provides three different usage scenarios, but they all use the same API interface:
1. Extension Development
Section titled “1. Extension Development”In extensions, you can directly use the global eidos
object:
// Query table data in current spaceeidos.currentSpace.table("tableId").rows.query()
// Operate on tables in specified spaceeidos.space("mySpace").table("tableId").rows.add({ name: "New Record", status: "active",})
2. HTTP API Calls
Section titled “2. HTTP API Calls”Through RPC interface, you can remotely call the same methods.
const response = await fetch("http://localhost:13127/rpc", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ space: "mySpace", method: "table('tableId').rows.query", params: [], }),})
const data = await response.json()console.log(data)
3. Headless Mode
Section titled “3. Headless Mode”Headless mode is a powerful feature of Eidos that allows you to run Eidos instances independently without relying on Eidos Desktop.
Core Concepts
Section titled “Core Concepts”Each Eidos Space is essentially an independent SQLite file, which means:
- Completely Independent: Each Space can be exported and run separately
- Lightweight Deployment: Only requires SQLite file to start a complete Eidos instance
- Easy Integration: Can be quickly integrated into any JavaScript/TypeScript runtime application
It revolves around DataSpace
. Build a DataSpace
instance, then you can use the same API for operations:
import { DataSpace } from "@eidos.space/core"
// 1. Initialize database adapterconst db = new DenoServerDatabase("./db.sqlite3")
// 2. Create DataSpace instanceconst dataSpace = new DataSpace({ db: db, activeUndoManager: false, dbName: "your-db-name", context: { // Runtime-specific API implementations setInterval: undefined, }, // TODO: Filesystem manager implementation efsManager: new EidosFileSystemManager(),})
Typical Use Cases
Section titled “Typical Use Cases”1. Blog System
const posts = await dataSpace.table("posts").rows.query()
2. Personal Website CMS
const pages = await dataSpace.table("pages").rows.query()
3. API Service Backend
import express from "express"
// RESTful API endpointsapp.get("/api/users", async (req, res) => { const users = await dataSpace.table("users").rows.query() res.json(users)})
app.post("/api/users", async (req, res) => { const newUser = await dataSpace.table("users").rows.add(req.body) res.json(newUser)})
Advantages
Section titled “Advantages”This unified design brings the following advantages:
- Low Learning Curve: Learn once, use everywhere
- Code Reusability: Extension code can be easily migrated to other environments
- Feature Consistency: Ensures all calling methods have the same capabilities
- High Development Efficiency: No need to learn different APIs for different scenarios