Skip to content

NpgsqlRestYour SQL is the API.

Annotate PostgreSQL functions and SQL files with comments to declare HTTP routes, auth, caching, retries, and rate limits. Get a fast, typed REST API โ€” no controllers, no models, no boilerplate.

~ npgsqlrest
$โ–Œ
4,500+
req/s on a single hostยน
74
production endpoints,
zero C# or Pythonยฒ
12K
lines of SQL
(no host-language code)
MIT
licensed,
open source
  • Declare, don't code โ€” caching, auth, retries, rate limiting โ€” all declared as SQL annotations.
  • PostgreSQL at the center โ€” the opposite of Clean Architecture: the database drives everything.
  • Types flow outward โ€” PostgreSQL types generate TypeScript clients automatically.
  • No middle tier โ€” no controllers, no models, no mapping layers, no boilerplate.

Declarative Annotations โ€‹

Declare what you want from your endpoint โ€” caching, authorization, timeouts, retries, rate limiting โ€” right where the SQL lives.

SQL File

sql
/*
HTTP GET /users/
@authorize admin, user
@cached
@cache_expires_in 30sec
@timeout 5min
@table_format = excel
@excel_file_name = users.xlsx
*/
select id, name, email, role
from users
where $1 is null or department_id = $1;

PostgreSQL Function

sql
create or replace function api.get_users(
  _department_id int
)
returns table (id int, name text, email text, role text)
language sql
begin atomic;
select id, name, email, role
from users
where
  _department_id is null
  or department_id = _department_id;
end;

comment on function api.get_users(int) is '
HTTP GET /users/
@authorize admin, user
@cached
@cache_expires_in 30sec
@timeout 10sec
@retry_strategy aggressive
@rate_limiter_policy authenticated_limit
@tsclient_module = users
';

From the Blog โ€‹


Build, Test, Publish and ReleaseLicenseGitHub StarsGitHub ForksCrafted with Claude
โค๏ธ Support this project: Patreon ยท Buy Me a Coffee
Released under the MIT License.
Copyright ยฉ 2024-2026 VB Consulting