REST from your database's catalog

An API woven
from your tables

restloom reads the tables you point it at and serves them as a REST API. Clients choose columns, filter, sort, page and pull in related rows from the query string, in requests you can type into curl. The database builds the JSON; your backend keeps the business logic.

PostgreSQL, MySQL, SQL Server, SQLite - Fastify, Express or plain Node - Apache-2.0

a to-do database, running in this page

Type a request.

Edit the request or pick an example. It runs here, in your browser, on a small to-do database.

What happens to a request

restloom checks every name in the request against the tables, columns and relations it read from your database, and refuses one it does not know before writing any SQL. Your authorize hook then decides whether this caller may ask. The dialect turns the request into SQL for your database, which sends the rows back already shaped as JSON.

GET /todos?status=eq.open&select=id,owner(name)AdapterFastify, Express, NodeParsenames checkedauthorizeyour hookPlanfilters, embedsDialectyour database's SQLDatabaserow securityJSON built by the database, streamed back as is

Every kind of relation

The examples on this site use a small to-do app. restloom found each of its relations by reading the foreign keys; nothing below was declared by hand.

owner / todostodo / stepstags / todosthrough todo_tagsmanager / usersusersidnameemailpassword_hash hiddenlimitmanager_idtodosidnamestatusowner_idestimatepinnedcreated_atstepsidtitletodo_idprioritydue_ontagsidname

Many-to-one

select=id,owner(name)

A todo's owner_id points to a user, so each todo has an owner. It comes back as an object, or null when there is none.

One-to-many

select=id,steps(title)&order=steps.count.desc

The steps point to their todo, so each todo has a list of steps. It comes back as an array you can filter, sort, page and count.

Many-to-many

select=id,tags(name)&tags.name=in.(work,home)

todo_tags pairs todos with tags. restloom walks through it for you, so you ask for a todo's tags directly.

What it does

Not GraphQL and not an ORM: plain REST over the schema you already have, with the business logic left where it belongs, in your code.

Ready to try it?