Skip to main content

Data API

Beta

Data API is in beta. Everything described on these pages already works, but names, buttons, and endpoint responses are still changing. A page may lag behind the product by a few days; if you notice a discrepancy, write to us in the dashboard chat — it helps.

Data API is available on the Pro plan. On the free plan the «Data API», «Авторизация» (Sign-in) and «Файлы» (Files) items on the database page are visible, but you can turn them on only after upgrading to Pro.

Data API is your database, available over HTTP. The frontend talks to it directly: no server to write, nothing to deploy, nothing to pay for an idle container.

The address is https://data.layero.ru/<database>, where <database> is the database slug from the panel. A request looks like this:

curl "https://data.layero.ru/moya-baza/rest/v1/entries?select=*&limit=5" \
-H "apikey: pk_live_…"

The contract is Supabase​

Paths, headers, the response shape, and error codes mirror PostgREST and GoTrue. This means @supabase/supabase-js works — the same client, the same examples, the same filter documentation:

import { createClient } from "@supabase/supabase-js";

const db = createClient("https://data.layero.ru/moya-baza", "pk_live_…");
const { data, error } = await db.from("entries").select("*").limit(5);

Compatibility exists for migration: a project written for Supabase runs without editing access policies. The runtime underneath is our own, and whatever we don't have responds with a refusal naming the missing capability, not a silent stub — see What's Missing.

Keys and roles​

A database has two keys, and the difference between them is the difference between roles inside the database itself.

KeyRole in the databaseWhere it lives
pk_live_… — publicanonin the frontend bundle, visible to every visitor
sk_live_… — secretservice_roleonly on your server

The key is passed in the apikey header (as with Supabase) or as authorization: Bearer …. A signed-in application user puts their token in authorization, while the key stays in apikey — the request then runs as authenticated. The roles are the same as in Supabase — policies and grants from its migrations work as written.

🚨 A key does not grant rights. It selects a role, and what that role can access is decided by grants and RLS policies inside the database itself. As in Supabase, a new table in public is open to anon and authenticated right away: without RLS it returns every row to anyone holding the public key. Turn RLS on as soon as you create a table — see Tables and REST.

Get the keys onto your machine:

layero data env # view
layero data env --write # write to .env.local

What to use to call it​

Nothing in particular — a request is just an ordinary fetch. If you want a client: our own thin @layero/data (calling functions) or @supabase/supabase-js (tables, filters, sign-in) — the contract is compatible with both. Details — What's Missing.

Which schemas are visible​

SchemaTablesFunctions
apiyesyes; a new function is closed until EXECUTE is granted
publicyesyes; a new function is callable right away — as in Supabase
appyesno

The gateway looks for tables in three schemas and for /rpc/ functions in api and public. The difference is the defaults: a public function can be called right after CREATE FUNCTION, an api function only after an explicit GRANT EXECUTE. So keep internal helpers in a separate closed schema, not in public. Details — Functions and RPC.

What's next​