REST from your database catalog
    DocumentationCheat sheetQuestionsDownloadSource
    Questions
    • How do I...?
    Start here
    • Getting started
    • What a table becomes
    • Compared with PostgREST
    Setting up
    • Tables, columns and relations
    • Security and hooks
    • Writes and procedures
    • Prefer: return=representation
    • Node, Fastify, Express
    Reading
    • select
    • /{key}
    • relation(...)
    • order
    • limit, offset
    • relation.order, .limit
    • count
    • count(), sum(), avg()...
    • "name"
    Filtering
    • eq, neq
    • gt, gte, lt, lte
    • in
    • like, ilike
    • match, imatch
    • is
    • ov, cs, cd
    • not
    • relation.column
    • or, and
    Databases
    • Supported databases
    • Adding a database
    Reference
    • Cheat sheet
    • Errors
    Reading

    Bring related rows along

    Put a relation's name in select, with the columns you want from it in parentheses.

    select=name,owner(name)select=name,steps(*)select=name,owner(name,manager(name))

    A to-one relation, like a todo's owner, comes back as an object, or null when there is none. A to-many relation, like a todo's steps or its tags, comes back as an array, empty when there is nothing.

    Relations are found from the foreign keys: todos.owner_id gives owner, and a table holding only two keys, like todo_tags, links todos and tags directly. relation(*) takes every visible column.

    Embeds nest. By default a request may walk two relations deep; a third level answers too_deep.

    Examples

    Each todo with its owner (to-one) and its tags (many-to-many).
    /todos?select=name,owner(name),tags(name)

    Asking the database...

    Each user, their todos, and the steps of each todo.
    /users?select=name,todos(name,steps(title))

    Asking the database...

    Walking the other way: a step, its todo, and the todo's owner.
    /steps?select=title,todo(name,owner(name))

    Asking the database...

    A table related to itself: each user's manager, and the users they manage, under the table's own name.
    /users?select=name,manager(name),users(name)

    Asking the database...

    Three relations deep is one too many.
    /todos?select=name,owner(name,manager(name,manager(name)))

    Asking the database...

    See alsoSort and page what is embedded Filter through a relation Sort the rows
    PreviousOne row by its keyNext Sort the rows
    restloom - a REST API generated from your database catalog
    DocumentationDownloadSource