NpgsqlRest 3.12.0
dotnet add package NpgsqlRest --version 3.12.0
NuGet\Install-Package NpgsqlRest -Version 3.12.0
<PackageReference Include="NpgsqlRest" Version="3.12.0" />
<PackageVersion Include="NpgsqlRest" Version="3.12.0" />
<PackageReference Include="NpgsqlRest" />
paket add NpgsqlRest --version 3.12.0
#r "nuget: NpgsqlRest, 3.12.0"
#:package NpgsqlRest@3.12.0
#addin nuget:?package=NpgsqlRest&version=3.12.0
#tool nuget:?package=NpgsqlRest&version=3.12.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
Most backend code shouldn't exist. If your API layer is just shuffling data between PostgreSQL and HTTP, why write it by hand? Write SQL, annotate it with a comment, and let the server figure out the rest. No controllers, no models, no mapping layers. The less code you maintain, the fewer bugs you ship.
<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.12.0 | 32 | 4/2/2026 |
| 3.11.1 | 101 | 3/13/2026 |
| 3.11.0 | 101 | 3/10/2026 |
| 3.10.0 | 104 | 2/25/2026 |
| 3.8.0 | 176 | 2/11/2026 |
| 3.7.0 | 131 | 2/7/2026 |
| 3.6.2 | 101 | 2/2/2026 |
| 3.6.1 | 94 | 2/2/2026 |
| 3.6.0 | 102 | 2/1/2026 |
| 3.5.0 | 94 | 1/28/2026 |
| 3.4.8 | 98 | 1/26/2026 |
| 3.4.7 | 97 | 1/21/2026 |
| 3.4.6 | 117 | 1/21/2026 |
| 3.4.5 | 110 | 1/19/2026 |
| 3.4.4 | 103 | 1/17/2026 |
| 3.4.3 | 107 | 1/16/2026 |
| 3.4.2 | 96 | 1/15/2026 |
| 3.4.1 | 96 | 1/15/2026 |
| 3.4.0 | 98 | 1/15/2026 |
| 3.3.1 | 101 | 1/13/2026 |