Skip to content

SDK Overview

Included free on every install. The GraphQL, gRPC and realtime clients call features that need a license.

Client packages exist for TypeScript and JavaScript only. They are published on npm under @lyeve-labs, and their source is public at github.com/lyeve-labs. There is no Go, Python or other client. From any other language, call the HTTP routes directly: each client-rest function maps to one of the routes in API endpoints.

PackageWhat it gives youNeeds
@lyeve-labs/clientThe core: createClient, ApiError, a retrying fetch (createRetryFetch), a PaginationIterator and the shared types. Start here
@lyeve-labs/client-restOne typed function per route for content, content types, users, API keys, permissions, tenants, webhooks and more
@lyeve-labs/client-reactReact: CmsProvider, useQuery, useMutation
@lyeve-labs/client-vueVue 3: CmsPlugin, useQuery, useMutation
@lyeve-labs/client-svelteSvelte 5 runes: createCmsClient, createAsyncStore, createMutation, createAuthStore
@lyeve-labs/client-graphqlcreateGraphQLClient: queries, mutations, and subscriptions over WebSocketgraphql
@lyeve-labs/client-grpcSchema and content calls over the plain HTTP mirror the gRPC feature serves beside its listenergrpc
@lyeve-labs/client-realtimecreateWSClient for WebSocket and SSEClient for Server-Sent Eventsrealtime

The last three work only against an instance that runs the feature. See the GraphQL API, gRPC API and Realtime.

Terminal window
pnpm add @lyeve-labs/client @lyeve-labs/client-rest

createClient takes a fetch function and default headers. The client-rest functions call paths such as /api/admin/schemas and /api/v1/content/post, and the two APIs listen on different ports, so pass a fetch that adds the right origin to each path:

import { createClient } from "@lyeve-labs/client";
import { getSchemas, listContent } from "@lyeve-labs/client-rest";
const origin = (path: string) =>
path.startsWith("/api/admin") ? "http://localhost:3001" : "http://localhost:3002";
const lyeveFetch: typeof fetch = (input, init) =>
fetch(typeof input === "string" && input.startsWith("/") ? origin(input) + input : input, init);
const client = createClient(lyeveFetch, { Authorization: `Bearer ${process.env.TOKEN}` });
const schemas = await getSchemas(client);
const posts = await listContent("post", client, 20);

In a browser served from behind a proxy that routes both paths, plain fetch works as it is. For a site that only reads content, send an API key instead of a token: { "X-API-Key": process.env.LYEVE_API_KEY }. The quickstart shows how to get a token, and API keys how to make a key.

createClient sends Content-Type: application/json, gives each request a 15 second timeout unless you pass your own signal, and throws an ApiError with status, message and the parsed body on any error answer. Troubleshooting says what each status means.