NpgsqlRest 3.13.0
dotnet add package NpgsqlRest --version 3.13.0
NuGet\Install-Package NpgsqlRest -Version 3.13.0
<PackageReference Include="NpgsqlRest" Version="3.13.0" />
<PackageVersion Include="NpgsqlRest" Version="3.13.0" />
<PackageReference Include="NpgsqlRest" />
paket add NpgsqlRest --version 3.13.0
#r "nuget: NpgsqlRest, 3.13.0"
#:package NpgsqlRest@3.13.0
#addin nuget:?package=NpgsqlRest&version=3.13.0
#tool nuget:?package=NpgsqlRest&version=3.13.0
NpgsqlRest
Automatic REST API for PostgreSQL | 6.1x faster than PostgREST
SQL files and PostgreSQL objects become REST endpoints. TypeScript clients are generated automatically.
"Simplicity is the ultimate sophistication." — Leonardo da Vinci
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.
<p align="center"> <img src="clean.png?v=2" alt="NpgsqlRest Architecture" width="340"> </p>
Install
| Method | Command |
|---|---|
| NPM | npm i 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.
From SQL to REST API
Write a SQL file:
-- sql/process_order.sql
-- HTTP POST
-- @authorize admin
-- @param $1 order_id
-- @result validate
select count(*) as found from orders where id = $1;
update orders set status = 'processing' where id = $1;
-- @result confirm
select id, status from orders where id = $1;
That gives you POST /api/process-order:
{"validate": [1], "result2": 1, "confirm": [{"id": 42, "status": "processing"}]}
And a generated TypeScript client with full type safety:
export async function processOrder(orderid: number) : Promise<{
validate: number[],
result2: number,
confirm: { id: number, status: string }[]
}> {
const response = await fetch(baseUrl + "/api/process-order", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ orderid }),
});
return await response.json();
}
No framework, no ORM, no boilerplate. Authorization, parameters, type safety — from a SQL file.
Endpoint Sources
| Source | What it's good for | Example |
|---|---|---|
| SQL Files | Simple queries, multi-command batch scripts, no DB deployment needed | sql/get_users.sql → GET /api/get-users |
| Functions & Procedures | Full PL/pgSQL power, static type checking, reusable logic | get_user_by_id(int) → GET /api/get-user-by-id |
| Tables & Views | Automatic CRUD | users table → GET/POST/PUT/DELETE /api/users |
SQL files are the easiest way to get started — drop a .sql file in a folder and you have an endpoint. Functions give you the full power of PL/pgSQL with true end-to-end type checking. Use both together, or whichever fits.
All sources share the same annotation system: @authorize, @param, @returns, @void, @single, @cached, @path, and 50+ others.
Features
- Multi-command SQL scripts — multiple statements in one file execute as a batch, returning named result sets
- TypeScript/JS code generation and
.httpfiles — types flow from PostgreSQL to your frontend - AOT-compiled native binaries — zero dependencies, instant startup
- 6.1x faster than PostgREST at 100 concurrent users
- 50+ comment annotations —
@authorize,@param,@returns,@void,@single,@result,@skip,@cached,@proxy, and more - Auth — cookie auth, Basic auth, JWT claims, role-based access,
@authorize,@allow_anonymous - Column-level encryption, security-sensitive endpoints, IP address binding
- Response caching with per-endpoint expiration control
- Rate limiting per endpoint
- SSE streaming via
RAISE INFO/NOTICEwith graceful shutdown - File uploads — large objects, file system, MIME filtering
- Reverse proxy — forward to upstream services, transform proxy responses
- HTTP custom types — PostgreSQL composite types that call external APIs and return structured responses
- Composite type support — nested JSON, arrays of composites,
@returnsto skip Describe - OpenAPI 3.0 spec generation
- CSV/Excel/HTML table format response handlers
How does it compare?
NpgsqlRest vs PostgREST vs Supabase
Documentation
npgsqlrest.github.io — getting started, configuration, annotations, examples.
Contributing
Contributions are welcome. Open a pull request with a description of your changes.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Npgsql (>= 10.0.2)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on NpgsqlRest:
| Package | Downloads |
|---|---|
|
NpgsqlRest.TsClient
Automatic Typescript Client Code Generation for NpgsqlRest |
|
|
NpgsqlRest.HttpFiles
Automatic HTTP Files Generation for NpgsqlRest |
|
|
NpgsqlRest.CrudSource
CRUD Source for NpgsqlRest |
|
|
NpgsqlRest.OpenAPI
Automatic HTTP Files Generation for NpgsqlRest |
|
|
NpgsqlRest.SqlFileSource
SQL File Source for NpgsqlRest - generates REST API endpoints from .sql files |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.13.0 | 39 | 5/1/2026 |
| 3.12.0 | 126 | 4/2/2026 |
| 3.11.1 | 113 | 3/13/2026 |
| 3.11.0 | 110 | 3/10/2026 |
| 3.10.0 | 113 | 2/25/2026 |
| 3.8.0 | 188 | 2/11/2026 |
| 3.7.0 | 137 | 2/7/2026 |
| 3.6.2 | 107 | 2/2/2026 |
| 3.6.1 | 105 | 2/2/2026 |
| 3.6.0 | 112 | 2/1/2026 |
| 3.5.0 | 102 | 1/28/2026 |
| 3.4.8 | 106 | 1/26/2026 |
| 3.4.7 | 104 | 1/21/2026 |
| 3.4.6 | 122 | 1/21/2026 |
| 3.4.5 | 118 | 1/19/2026 |
| 3.4.4 | 114 | 1/17/2026 |
| 3.4.3 | 112 | 1/16/2026 |
| 3.4.2 | 104 | 1/15/2026 |
| 3.4.1 | 104 | 1/15/2026 |
| 3.4.0 | 104 | 1/15/2026 |