TypeScript SDK
Full documentation for the @hypermeshdb/client npm package.
See the TypeScript Quickstart for a fast introduction.
Install
Section titled “Install”npm install @hypermeshdb/clientConstructor
Section titled “Constructor”import { HyperMeshClient, ClientOptions } from "@hypermeshdb/client";
const db = new HyperMeshClient({ baseUrl: "http://localhost:8000", apiKey: "hmdb_yoursecretkey", timeoutMs: 30000, fetch: customFetchImpl, // optional});Full API reference
Section titled “Full API reference”See the REST API reference for the underlying endpoints. The TypeScript SDK exposes identical semantics — each method maps 1:1 to a REST call.
| Method | REST | Requires |
|---|---|---|
health() | GET /health | readonly |
live() | GET /health/live | none |
ready() | GET /health/ready | none |
walStatus() | GET /v1/wal | readonly |
listTables() | GET /v1/tables | readonly |
getTable(name) | GET /v1/tables/:name | readonly |
createTable(...) | POST /v1/tables | admin |
dropTable(name) | DELETE /v1/tables/:name | admin |
listIndexes(table?) | GET /v1/indexes | readonly |
createIndex(table, col) | POST /v1/indexes | admin |
dropIndex(table, col) | DELETE /v1/indexes/:t/:c | admin |
execute(cypher, params?) | POST /v1/query | varies |
queryRange(start, end, table?) | GET /v1/hyperedges | readonly |
queryNode(nodeId, table?) | GET /v1/hyperedges/node/:id | readonly |
insert(options) | POST /v1/hyperedges | readwrite |
delete(ts, members) | DELETE /v1/hyperedges | readwrite |
compact(options?) | POST /v1/hyperedges/compact | readwrite |
setAutocompact(options) | POST /v1/autocompact | readwrite |
batch(operations) | POST /v1/batch | readwrite |
analytics(table, measure, params?) | POST /v1/analytics/:t/:m | readonly |
backup(dir, compactFirst?) | POST /v1/backup | admin |
listKeys() | GET /v1/keys | admin |
createKey(role?, desc?) | POST /v1/keys | admin |
revokeKey(keyId) | DELETE /v1/keys/:id | admin |
Error handling
Section titled “Error handling”import { HyperMeshError } from "@hypermeshdb/client";
try { await db.insert({ event_ts: 1, members: [] }); // invalid: empty members} catch (err) { if (err instanceof HyperMeshError) { console.log(err.statusCode); // 400 console.log(err.detail); // server detail object }}TypeScript types
Section titled “TypeScript types”All types are exported from @hypermeshdb/client:
import type { ClientOptions, QueryResult, QueryPlan, Row, Hyperedge, RangeQueryResult, TableDef, IndexDef, HealthStatus, WalStatus, InsertOptions, CompactOptions, AutocompactOptions, BatchOperation, BatchResult, BatchOpResult, BatchOpType, AnalyticsResult, ApiKeyInfo, ApiKeyCreated, ApiKeyRole, BackupResult,} from "@hypermeshdb/client";