MooseStack provides flexible approaches for building HTTP APIs to expose your data. You can use Moose's built-in Api class for simple GET endpoints, or bring popular web frameworks like Express, Koa, Fastify, or FastAPI for advanced features and custom middleware.
These framework integrations give you two complementary integration paths:
WebApp so MooseStack deploys everything together and injects auth, client, and sql helpers on every request.Moose's built-in Api class provides simple GET endpoints with automatic type validation and OpenAPI documentation. This is ideal for straightforward data queries without complex routing or middleware requirements.
Use Native Api class when you need:
Use the WebApp class to mount your framework in your MooseStack project alongside tables, streams, and workflows.
Why embed the framework:
client, sql, jwt) in every handler through getMooseUtilsIf you already have an application server, call MooseStack directly with the client SDKs—no MooseStack deployment required. Works great for Next.js, Rails, Python microservices, or anything else that can make HTTP requests.
Here's the client pattern:
import { MooseClient, sql } from "@514labs/moose-lib";import { UserTable } from "./tables/UserTable"; const client = new MooseClient(); export async function listUsers(limit = 25) { const result = await client.query.execute( sql` SELECT ${UserTable.columns.id}, ${UserTable.columns.name}, ${UserTable.columns.email} FROM ${UserTable} WHERE ${UserTable.columns.status} = 'active' LIMIT ${limit} ` ); return await result.json();}For more examples, see the Querying Data guide.
For basic GET endpoints that query your OLAP tables, MooseStack provides built-in Analytics APIs using the Api class.
WebApp currently ships adapters for Express, Koa, Fastify, raw Node.js, and FastAPI. Frameworks like Next.js can call MooseStack today through the client pattern above.
The WebApp class is the bridge between your web framework and MooseStack. It handles:
All frameworks can access your OLAP database through MooseStack's injected utilities:
import { getMooseUtils } from "@514labs/moose-lib"; const moose = getMooseUtils(req);const { client, sql, jwt } = moose;Each WebApp must specify a unique mount path where it will be accessible. Mount paths have specific rules:
/ (root path)/admin, /api, /consumption, /health, /ingest, /mcp, /moose, /ready, /workflowsValid: /myapi, /v1/analytics, /custom/endpoint
Invalid: /, /myapi/, /api/myendpoint
MooseStack's native Api class provides built-in validation and OpenAPI documentation. See the Analytics API documentation for a guided walkthrough.