Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ub.bitbros.in/llms.txt

Use this file to discover all available pages before exploring further.

GET /api/data/:collectionName

Returns a list of documents from the specified collection. Supports pagination, sorting, and field-level filtering via query parameters.
/api/data/users* is blocked for all keys. Use /api/userAuth/* for user management.

Required header

x-api-key: your pk_live_… or sk_live_… key.

Path parameters

collectionName
string
required
The name of the collection to query (e.g., posts, comments, inventory).

Query parameters

page
number
Page number for pagination. Defaults to 1.
limit
number
Number of documents per page. Defaults to 20.
sort
string
Field to sort by. Prefix with - for descending order (e.g., sort=-createdAt for newest first, sort=title for ascending alphabetical).
field_op
string
Filter documents by field value. Append an operator suffix to the field name for comparisons (e.g., _gt, _lt, _ne, _in, _regex). For exact matches, use the field name without a suffix. Example: status=published&views_gt=100
include_deleted
boolean
Setting include_deleted to true includes soft-deleted documents; it defaults to false

RLS behavior

If the collection has RLS enabled:
  • public-read mode: anyone can read all documents with a valid x-api-key.
  • private mode: requires Authorization: Bearer <accessToken> — only the owner’s documents are returned.

Response fields

success
boolean
true when the request succeeded.
data
object
Object containing the results and pagination metadata.
message
string
Human-readable status message.

Code examples

const params = new URLSearchParams({
  page: '1',
  limit: '10',
  sort: '-createdAt',
  status: 'published',
  include_deleted: 'true'
});

const res = await fetch(
  `https://api.ub.bitbros.in/api/data/posts?${params}`,
  {
    headers: {
      'x-api-key': 'pk_live_YOUR_KEY'
    }
  }
);

const { data } = await res.json();
// data.items contains the array of matching documents
// data.total contains the total count

Success response

{
  "success": true,
  "data": {
    "items": [
      {
        "_id": "64fd1234abcd5678ef901234",
        "title": "Why BaaS is the future",
        "status": "published",
        "isDeleted": false,
        "deletedAt": null,
        "createdAt": "2024-01-15T10:30:00.000Z"
      },
      {
        "_id": "64fd5678abcd1234ef905678",
        "title": "Getting started with urBackend",
        "status": "published",
        "isDeleted": true,
        "deletedAt": "2026-05-20T10:30:00.000Z",
        "createdAt": "2024-01-14T08:00:00.000Z"
      }
    ],
    "total": 42,
    "page": 1,
    "limit": 10
  },
  "message": "Data fetched successfully"
}

Errors

StatusCause
401 UnauthorizedMissing/invalid API key, or missing Bearer token on a private collection
403 Forbiddenpk_live write attempt without RLS, or quota exceeded
404 Not FoundCollection does not exist