REST & GraphQL API
Este conteúdo não está disponível em sua língua ainda.
Overview
Section titled “Overview”Rebase automatically generates a complete API from your collection definitions:
- REST API — CRUD endpoints for every collection at
/api/data/:slug - GraphQL API — Auto-generated schema at
/api/graphql - OpenAPI spec — Machine-readable spec at
/api/docs - Swagger UI — Interactive API explorer at
/api/swagger(dev mode only)
No code is required — define your collections and the API appears automatically.
REST Endpoints
Section titled “REST Endpoints”For each collection, the following endpoints are generated:
| Method | Path | Description |
|---|---|---|
GET | /api/data/:slug | List entities |
GET | /api/data/:slug/count | Count entities |
GET | /api/data/:slug/:id | Get a single entity |
POST | /api/data/:slug | Create an entity |
PUT | /api/data/:slug/:id | Update an entity |
DELETE | /api/data/:slug/:id | Delete an entity |
Subcollection Routes
Section titled “Subcollection Routes”Nested relations are accessible via URL paths:
GET /api/data/authors/42/posts → list author's postsGET /api/data/authors/42/posts/7 → get a specific post by authorPOST /api/data/authors/42/posts → create a post for authorPUT /api/data/authors/42/posts/7 → update the postDELETE /api/data/authors/42/posts/7 → delete the postAuthentication
Section titled “Authentication”All data endpoints require authentication by default. Include a Bearer token in the Authorization header:
curl -H "Authorization: Bearer <access-token>" \ https://api.example.com/api/data/productsFor server-to-server calls, use the service key:
curl -H "Authorization: Bearer <service-key>" \ https://api.example.com/api/data/productsFiltering
Section titled “Filtering”Use PostgREST-style query parameters to filter results. The format is ?field=operator.value:
# Exact matchGET /api/data/products?active=eq.true
# Comparison operatorsGET /api/data/products?price=gt.100GET /api/data/products?price=lte.50
# Multiple filters (AND)GET /api/data/products?active=eq.true&price=gt.10
# IN operator — match any value in a setGET /api/data/products?status=in.(draft,published)
# NOT INGET /api/data/products?status=nin.(archived,deleted)
# Array containsGET /api/data/products?tags=cs.electronics
# Array contains anyGET /api/data/products?tags=csa.(electronics,books)Filter Operators
Section titled “Filter Operators”| Operator | Meaning | Example |
|---|---|---|
eq | Equals (==) | ?active=eq.true |
neq | Not equals (!=) | ?status=neq.draft |
gt | Greater than (>) | ?price=gt.100 |
gte | Greater or equal (>=) | ?price=gte.100 |
lt | Less than (<) | ?price=lt.50 |
lte | Less or equal (<=) | ?price=lte.50 |
in | In array | ?status=in.(a,b,c) |
nin | Not in array | ?status=nin.(a,b) |
cs | Array contains | ?tags=cs.value |
csa | Array contains any | ?tags=csa.(a,b) |
Logical Operators
Section titled “Logical Operators”Use or and and for complex conditions:
# OR: match products that are either cheap or on saleGET /api/data/products?or=(price.lt.10,on_sale.eq.true)
# AND: explicit conjunctionGET /api/data/products?and=(active.eq.true,price.gt.0)Sorting
Section titled “Sorting”Use orderBy with the format field:direction:
# Sort by price descendingGET /api/data/products?orderBy=price:desc
# Sort by name ascending (default)GET /api/data/products?orderBy=name:ascPagination
Section titled “Pagination”Use limit and offset, or page:
# Limit and offsetGET /api/data/products?limit=20&offset=40
# Page-based (uses default limit of 20)GET /api/data/products?page=3The default limit is 20, the maximum is 100.
Response Format
Section titled “Response Format”List responses include pagination metadata:
{ "data": [ { "id": 1, "name": "Widget", "price": 29.99 }, { "id": 2, "name": "Gadget", "price": 49.99 } ], "meta": { "total": 150, "limit": 20, "offset": 0, "hasMore": true }}Single entity responses return a flat object:
{ "id": 1, "name": "Widget", "price": 29.99, "created_at": "2026-01-15T10:30:00Z"}Text Search
Section titled “Text Search”Use searchString for full-text search across string fields:
GET /api/data/products?searchString=wireless%20keyboardRelation Inclusion
Section titled “Relation Inclusion”Use the include parameter to embed related entities:
# Include specific relationsGET /api/data/articles?include=author,categories
# Include all relationsGET /api/data/articles?include=*Included relations are embedded directly in the response:
{ "id": 1, "title": "Getting Started", "author_id": 42, "author": { "id": 42, "name": "Jane Doe", "email": "jane@example.com" }}Field Selection
Section titled “Field Selection”Use fields to select specific columns:
GET /api/data/products?fields=id,name,priceGraphQL API
Section titled “GraphQL API”A GraphQL endpoint is automatically generated at /api/graphql:
query { products(limit: 10, orderBy: "price:desc") { id name price category { id name } }}In development mode, an interactive GraphiQL IDE is available at /api/graphiql.
OpenAPI / Swagger
Section titled “OpenAPI / Swagger”- OpenAPI spec:
GET /api/docs— Returns the full OpenAPI 3.0 JSON specification - Swagger UI:
GET /api/swagger— Interactive API explorer (dev mode only)
The OpenAPI spec is auto-generated from your collection definitions and includes all endpoints, query parameters, and response schemas.
API Keys
Section titled “API Keys”For external integrations, you can use API keys instead of user tokens. API keys support per-collection permission scoping (read, write, delete).
Metadata Endpoint
Section titled “Metadata Endpoint”Get a list of all available collections and their structure:
GET /api/collectionsNext Steps
Section titled “Next Steps”- Client SDK — Type-safe client for the REST API
- Collections — Define your data schema
- Security Rules (RLS) — Control access per row