Skip to main content

Views

A view is a filtered subset of a collection. Unlike traditional database views, RestAPI.com views are fully updatable — you can create, update, and delete items through a view.

What Views Do

  • Filter items — Show only items matching criteria
  • Limit properties — Expose only selected fields
  • Control access — Use with security rules for fine-grained permissions
  • Full CRUD support — Create, read, update, and delete through views

URL Structure

Views share the same namespace as collections:

https://<region>.restapi.com/<api-name>/<view-name>

Creating a View

  1. Open the Developer Portal
  2. Navigate to your API's schema
  3. Create a new view
  4. Select the base collection
  5. Configure filter and properties

Filtering

Apply a filter to show only matching items:

FilterResult
itemsInStock eq 0Out of stock items only
status eq "active"Active items only
price lt 100Items under $100

Filter Operators

OperatorDescriptionExample
eqEqual tostatus eq "active"
neNot equal tostatus ne "deleted"
gtGreater thanprice gt 100
ltLess thanstock lt 10
geGreater than or equalrating ge 4
leLess than or equalpriority le 3
conContains (strings)name con "pro"
nconNot containsname ncon "test"
swStarts withname sw "Pro"
ewEnds withname ew "Plus"

Case-insensitive: Append ~ to operators (e.g., eq~, con~)

Combine conditions: Use and, or, and parentheses:

status eq "active" and (priority eq "high" or priority eq "urgent")

Dynamic Expressions

Use exp() for dynamic values in filters. The expression must be wrapped in single or double quotes.

tip

When using + in URLs, encode it as %2B (e.g., exp('now() %2B 7D')).

createdAt gt exp('now() - 30D')    # Items from last 30 days
expiresAt lt exp('now()') # Expired items
dueDate le exp('now() + 7D') # Due within a week

Date/time tokens:

TokenDescriptionExample
now()Current UTC date-timenow()
DDaysnow() + 7D
HHoursnow() + 24H
MMinutesnow() + 30M
SSecondsnow() + 60S

Tokens are case-insensitive. All date/time values are handled in UTC.

Example

Base collection (products):

SKUNamePriceStock
A1Widget A29.9910
B2Widget B19.990
C3Widget C39.995
D4Widget D24.990

View with filter stock eq 0:

SKUNamePrice
B2Widget B19.99
D4Widget D24.99

Selecting Properties

Choose which properties to include in the view:

  • Include all properties from the base collection
  • Select a subset of properties

Omitting properties hides them from API consumers.

Updatable Views

Views support all HTTP methods just like collections:

MethodDescription
GETRead items matching the view filter
POSTCreate new items (must match view filter)
PUTReplace items within the view
PATCHUpdate items within the view
DELETEDelete items within the view

When creating items through a view, the new item must satisfy the view's filter criteria.

View vs Collection

FeatureCollectionView
Store dataYesNo (references collection)
Create itemsYesYes
Update itemsYesYes
Delete itemsYesYes
Filter dataVia query paramsBuilt-in filter
Independent access rulesYesYes

Use Cases

Public API

Expose a view with limited fields for public access:

products-public → Shows: name, description, price
products (internal) → Shows: all fields including cost, supplier

Status-Based Access

Create views for different item states:

orders-pending → filter: status eq "pending"
orders-shipped → filter: status eq "shipped"
orders-completed → filter: status eq "completed"

Role-Based Data

Combine views with security rules:

my-orders → filter: userId eq {{user.id}}

Security

Views work with Security Policy Rules for row-level security. See Security Policies for details.