API Reference
Complete reference for all Omni Rest endpoints.
Overview
Each Prisma model automatically gets 8 REST endpoints generated instantly without configuration.
Query Parameters
Omni Rest supports powerful filtering, sorting, and pagination via standard query parameters.
GET /api/product?limit=10&offset=20| Parameter | Type | Default | Description |
|---|---|---|---|
limit | number | 10 | Maximum number of records to return |
offset | number | 0 | Number of records to skip |
Cursor-Based Pagination
For larger datasets, cursor-based pagination is significantly faster (O(1)) than offset.
// 1. Initial request
GET /api/product?limit=20&paginationMode=cursor
// Response includes nextCursor
// { "data": [...], "meta": { "hasMore": true, "nextCursor": "eyJpZCI6MjB9" } }
// 2. Next page request
GET /api/product?limit=20&paginationMode=cursor&cursor=eyJpZCI6MjB9- O(1) Performance: Fast queries regardless of depth.
- Stable results: No skipped or duplicated items if records are inserted during pagination.
- Note: In cursor mode, the response
metaobject omitstotalandpage, replacing them withnextCursorandhasMore.
Endpoints
LIST - Get All Records
GET /api/:model
Returns a paginated list of records.
Query Parameters:
limit(optional): Number of records per pageoffset(optional): Number of records to skip (offset mode only)paginationMode(optional):offset(default) orcursorcursor(optional): Base64 encoded cursor for paginationsort(optional): Sort field and direction, e.g.name:ascor_count.posts:descsearch(optional): Case-insensitive search across all String fieldsselect/fields(optional): Comma-separated field names to return- Filter parameters (optional): See filtering section
CREATE - Create New Record
POST /api/:model
Creates a new record. Provide a JSON object with model fields (excluding auto-generated fields like id, createdAt).
{
"name": "New Product",
"price": 29.99,
"inventory": 100
}READ - Get Single Record
GET /api/:model/:id
Returns a single record by ID.
Path Parameters:
id- Record ID
UPDATE - Replace Record
PUT /api/:model/:id
Replaces an entire record.
Path Parameters:
id- Record ID
Request Body: Complete JSON object with all required fields.
PATCH - Update Record
PATCH /api/:model/:id
Partially updates a record.
Path Parameters:
id- Record ID
Request Body: JSON object with only the fields to update.
{
"price": 899.99,
"inventory": 50
}DELETE - Delete Record
DELETE /api/:model/:id
Deletes a record by ID. If softDelete: true is configured and the model has a deletedAt or isActive field, the record is soft-deleted instead of destroyed.
Path Parameters:
id- Record ID
BULK UPDATE - Update Multiple Records
PATCH /api/:model/bulk/update
Updates multiple records in one request.
{
"ids": [1, 2, 3],
"data": {
"status": "active",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
}BULK DELETE - Delete Multiple Records
DELETE /api/:model/bulk/delete
Deletes multiple records in one request.
{
"ids": [1, 2, 3]
}Error Responses
All endpoints return consistent error responses:
{
"error": {
"message": "Record not found",
"code": "NOT_FOUND",
"details": {}
}
}Authentication
If your application requires authentication, implement it as middleware before mounting the omni-rest adapter:
app.use("/api", authenticateMiddleware, expressAdapter(prisma));