PRACTICAL FIELD GUIDE

REST API filter syntax and operators, with examples

REST API filters usually go in the query string as column[operator]=value, such as ?price[gte]=10. MCPBackend accepts eight operators (eq, ne, gt, gte, lt, lte, in and like) rather than arbitrary SQL expressions, so build query parameters from the generated contract and known columns.

MCPBackend editorial team · · Examples are illustrative

The short answer

There is no single standard for REST API filtering, but most APIs use one of a few query-string styles, and the most common is the bracket style: ?price[gte]=10&status=active. The column name comes first, the operator goes in square brackets, and a bare name means equals. That is the syntax MCPBackend uses.

MCPBackend accepts exactly eight operators: eq, ne, gt, gte, lt, lte, in and like. Every query parameter that names a column is a filter, and several filters combine with AND. The reserved parameters limit, offset, page, sort and order are not filters.

Anything else (a guessed operator such as [contains] or [between], a column that does not exist, or a raw SQL fragment) is rejected with HTTP 400 and the code bad_request, and the message names the problem, for example Unsupported filter operator: "contains".

Filter operators cheat sheet

  • eq (default): ?status=active or ?status[eq]=active. Exact match, like SQL =.
  • ne: ?status[ne]=archived. Not equal (SQL !=). Rows where the column is NULL do not match, because SQL comparisons with NULL are never true.
  • gt and gte: ?created_at[gte]=2026-10-01. Greater than (>), or greater than or equal (>=).
  • lt and lte: ?price[lt]=50. Less than (<), or less than or equal (<=). Combine with gte for a range: ?price[gte]=10&price[lt]=50.
  • in: ?status[in]=open,pending. Matches any value in a comma-separated list (SQL IN). Spaces around values are trimmed, and an empty list matches nothing.
  • like: ?title[like]=invoice. Contains search: the value is wrapped as %invoice% and is case-insensitive for plain ASCII letters. See the LIKE guide for wildcards and limits.

REST API filter syntax styles compared

If you are designing an API or reading someone else's, these are the conventions you will meet. They express the same filter, price at least 10 and status open or pending, in different ways:

  • Bracket operators (LHS): ?price[gte]=10&status[in]=open,pending. Used by MCPBackend; Stripe uses the same shape for ranges such as created[gte]. Easy to read and to build with URLSearchParams.
  • Operator in the value (RHS): ?price=gte:10&status=in:open,pending. Keeps parameter names plain, but every value has to be parsed and a literal colon needs escaping.
  • PostgREST and Supabase: ?price=gte.10&status=in.(open,pending). A dot-separated operator prefix, plus an or=(...) parameter for OR conditions.
  • OData: ?$filter=price ge 10 and (status eq 'open' or status eq 'pending'). A small expression language that supports AND, OR and grouping, at the cost of a parser.
  • JSON:API: ?filter[status]=open. The spec reserves the filter parameter but leaves the strategy to each API, so the operators vary.

Common filter examples

# Open or pending tasks due by the end of November, soonest first
GET /v1/{projectId}/db/tasks?status[in]=open,pending&due_date[lte]=2026-11-30&sort=due_date&order=asc

# Orders between $10 and $50 (gte and lt on the same column)
GET /v1/{projectId}/db/orders?total[gte]=10&total[lt]=50

# Everything except archived rows (rows with a NULL status are excluded too)
GET /v1/{projectId}/db/posts?status[ne]=archived

# Titles containing "invoice", 25 per page, second page
GET /v1/{projectId}/db/documents?title[like]=invoice&limit=25&page=2

# Created this month (store timestamps as ISO 8601 text)
GET /v1/{projectId}/db/leads?created_at[gte]=2026-11-01

Build the query string safely

Use URLSearchParams rather than string concatenation, so values with &, = or spaces are encoded and cannot turn into extra filters. Brackets in the key are encoded too, which the API accepts.

const params = new URLSearchParams({
  "status[in]": "open,pending",
  "due_date[lte]": "2026-11-30",
  "title[like]": search,       // user input, safely encoded
  sort: "due_date",
  order: "asc",
  limit: "25",
});
const res = await fetch(`${base}/v1/${projectId}/db/tasks?${params}`, {
  headers: { authorization: `Bearer ${token}` },
});
if (res.status === 400) {
  const { error } = await res.json(); // e.g. Unsupported filter operator: "contains"
  throw new Error(error.message);
}

What the filter syntax cannot do

  • No OR across columns. Filters are joined with AND. For "status is open OR assignee is me", make two requests and merge them, or add a column that captures the condition.
  • Dates compare as stored values. Store dates as ISO 8601 text (2026-10-29 or a full timestamp) so text comparison sorts in time order.
  • One value per parameter name. Repeat a column with different operators (price[gte] and price[lt]), not the same key twice: if a key appears twice, only one value is used.
  • Row policies still apply. Owner-only tables add an owner filter on the server, so an end user never sees other users' rows whatever filters you send.

Put it into practice

  1. Choose a supported field and operator for the intended comparison.
  2. Encode the query parameters with a URL builder rather than concatenating untrusted input.
  3. Test matching, nonmatching and invalid filters and handle a 400 response visibly.

What this looks like

ILLUSTRATIVE EXAMPLE

A status equality filter and a date comparison can form a supported request, while a guessed SQL fragment is not a filter API.

A boundary to keep clear

Do not assume operators from another backend are accepted. Unknown columns and operators should be treated as contract errors.

MCPBackend context

Use get_project_api or the dashboard's generated OpenAPI contract for your project's exact data-plane routes. Machine keys and end-user tokens have different access models. Treat error status and JSON code together, keep credentials out of URLs, and test against disposable records before changing real data.

Take the next step

Inspect the current project contract, try the change with disposable data, and verify the result through the same credentials your app will use. Record the expected response and one denied-access case before release.

Frequently asked questions

What is the standard syntax for filtering in a REST API?

There is no single standard. The common styles are bracket operators (?price[gte]=10), operators in the value (?price=gte:10), PostgREST's ?price=gte.10 and OData's $filter expressions. Pick one, document the operators and return a 400 for anything else.

Which filter operators does the MCPBackend REST API support?

eq (the default), ne, gt, gte, lt, lte, in and like. Write them as column[op]=value, for example price[gte]=10 or status[in]=open,pending.

How do I filter a range, such as between two dates?

Use two operators on the same column: ?created_at[gte]=2026-10-01&created_at[lt]=2026-11-01. There is no between operator.

Why does my filter return 400 bad_request?

The column is not in the table, the operator is not one of the eight supported ones, or the parameter name has characters other than letters, digits and underscores. The error message names which.

Can I filter with OR?

Not in one request. Multiple filters always combine with AND. Use in for several values of one column, or make separate requests and merge the results on the client.

Are operator names case-sensitive?

No. price[GTE]=10 and price[gte]=10 are the same filter. Column names must match the schema exactly.

Sources and further reading

These references explain the underlying protocols and design principles. For supported MCPBackend operations and exact request shapes, inspect your project’s generated API contract.