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.
Packages
Section titled “Packages”| Package | What it gives you | Needs |
|---|---|---|
@lyeve-labs/client | The core: createClient, ApiError, a retrying fetch (createRetryFetch), a PaginationIterator and the shared types. Start here | |
@lyeve-labs/client-rest | One typed function per route for content, content types, users, API keys, permissions, tenants, webhooks and more | |
@lyeve-labs/client-react | React: CmsProvider, useQuery, useMutation | |
@lyeve-labs/client-vue | Vue 3: CmsPlugin, useQuery, useMutation | |
@lyeve-labs/client-svelte | Svelte 5 runes: createCmsClient, createAsyncStore, createMutation, createAuthStore | |
@lyeve-labs/client-graphql | createGraphQLClient: queries, mutations, and subscriptions over WebSocket | graphql |
@lyeve-labs/client-grpc | Schema and content calls over the plain HTTP mirror the gRPC feature serves beside its listener | grpc |
@lyeve-labs/client-realtime | createWSClient for WebSocket and SSEClient for Server-Sent Events | realtime |
The last three work only against an instance that runs the feature. See the GraphQL API, gRPC API and Realtime.
Point the client at your instance
Section titled “Point the client at your instance”pnpm add @lyeve-labs/client @lyeve-labs/client-restcreateClient 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.
Related
Section titled “Related”- API endpoints: the routes behind every function.
- Validate tokens with JWKS: check a LyEve token in your own service without a shared secret.
- Developer guide: the order to learn the APIs in.