Skip to content
@NpgsqlRest

NpgsqlRest

NpgsqlRest

Build, Test, Publish and Release 2400+ integration tests License Sponsor GitHub Stars GitHub Forks

Your SQL is the API

Automatic REST API for PostgreSQL | 6.1x faster than PostgREST

SQL files and PostgreSQL objects become REST endpoints. TypeScript and Dart clients are generated automatically. Tests are SQL files too.

4,500+ req/s on a single host · 2,484 integration tests · 12K LOC SQL in production · MIT licensed

Documentation | Quick Start | Annotations | Configuration | Blog

SQL is declarative — your API should be too. With NpgsqlRest, you write SQL and annotate it with comments to declare what you want from your endpoint: caching, timeouts, retries, authorization, rate limiting, and everything in between. No controllers, no models, no mapping layers. Backend features become simple declarations on your SQL objects, putting PostgreSQL at the dead center of your architecture — the opposite of Clean Architecture, which treats the database as a detail. Here, PostgreSQL is the architecture.

From SQL to REST API

-- sql/process_order.sql
-- HTTP POST
-- @authorize admin
-- @result validate
-- @single
select count(*) as found from orders where id = :order_id;
update orders set status = 'processing' where id = :order_id;
-- @result confirm
select id, status from orders where id = :order_id;

That gives you POST /api/process-order:

{"validate": 1, "result2": 1, "confirm": [{"id": 42, "status": "processing"}]}

…plus a generated TypeScript client with full type safety. No framework, no ORM, no boilerplate.

Key Features

  • Two endpoint sources — plain .sql files (drop a file in a folder, get an endpoint) and PostgreSQL functions and procedures, sharing the same 50+ comment annotations: @authorize, @cached, @path, @proxy, and more
  • Tests are SQL files toonpgsqlrest --test invokes the real endpoint pipeline in-process, on the test's own transaction, with endpoint-coverage gating
  • Watch mode--watch restarts on SQL file, configuration, and even database routine changes; the TypeScript client regenerates every cycle
  • Typed clients — TypeScript fetch modules with optional TanStack Query (React Query) v5 hooks, and Dart clients for Flutter
  • AI-agent ready@mcp exposes any endpoint as a Model Context Protocol tool with the same auth and rate limits, plus OpenAI/Anthropic tool schemas and llms.txt
  • Auth built in — cookie auth, Basic auth, JWT claims, external OAuth, passkeys, role-based @authorize
  • Production-grade — response caching, per-endpoint rate limiting, retries, multi-host failover, SSE streaming, file uploads, reverse proxy
  • Output formats — JSON, CSV, Excel, HTML table rendering, and OpenAPI 3.0/3.1 spec generation
  • AOT-compiled native binaries — zero dependencies, instant startup

Installation

Method Command
NPM npm install npgsqlrest
Bun bun add --trust npgsqlrest
Deno deno install --allow-scripts=npm:npgsqlrest npm:npgsqlrest
Docker docker pull vbilopav/npgsqlrest:latest
Direct Download Releases
.NET Library dotnet add package NpgsqlRest

Requires PostgreSQL >= 13. Native executables have zero runtime dependencies. See the Installation Guide.

Claude Code Skill

An official Claude Code skill teaches the agent the exact annotations and configuration options for the current release — install it per project or per user and build endpoints by describing them.

Support This Project ❤️

NpgsqlRest is free, MIT-licensed, and built by one person out of passion. If it saves you time, GitHub Sponsors is the primary way to support it — Patreon and Buy Me a Coffee work too. Read more on the support page.

Contributing

Contributions are welcome — see CONTRIBUTING.md. Small, well-scoped issues are labeled good-first-issue.

Security

Please report vulnerabilities privately via GitHub Private Vulnerability Reporting — see SECURITY.md. Do not open public issues for security problems.

License

MIT

Pinned Loading

  1. NpgsqlRest NpgsqlRest Public

    Transform Your PostgreSQL Database into a Production-Ready, Blazing-Fast Standalone REST API Web Server With Static Type Checking and Automatic Code Generation

    C# 123 10

Repositories

Showing 8 of 8 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…