Documentation
API Reference

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
ParameterTypeDefaultDescription
limitnumber10Maximum number of records to return
offsetnumber0Number 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 meta object omits total and page, replacing them with nextCursor and hasMore.

Endpoints

LIST - Get All Records

GET /api/:model

Returns a paginated list of records.

Query Parameters:

  • limit (optional): Number of records per page
  • offset (optional): Number of records to skip (offset mode only)
  • paginationMode (optional): offset (default) or cursor
  • cursor (optional): Base64 encoded cursor for pagination
  • sort (optional): Sort field and direction, e.g. name:asc or _count.posts:desc
  • search (optional): Case-insensitive search across all String fields
  • select / 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));