Skip to content

NpgsqlRestAutomatic PostgreSQL Web Server

Create professional, high-performance HTTP REST APIs for PostgreSQL databases in minutes and generate type-safe client code automatically.

NpgsqlRest
NpgsqlRest Architecture - PostgreSQL at the center with automatic REST API, TypeScript generation, authentication, caching, and more

Clean PostgreSQL Architecture - PostgreSQL First Architecture - PostgreSQL Driven Architecture

  • Schema as contract — Tables, views, and functions become REST endpoints
  • SQL comments as config — Routes, auth, caching declared where the logic lives
  • Types flow outward — PostgreSQL types generate TypeScript clients automatically
  • No middle tier — No ORM mismatch, no N+1 queries, no boilerplate

Declarative Annotations

Simple comment annotations turn PostgreSQL functions into fully-featured REST endpoints.

sql
-- REST endpoint with custom path and authentication
create function api.get_user(p_id int)
returns setof user_info as $$
select id, name, email, role from users where id = p_id;
$$ language sql;

comment on function api.get_user(int) is '
HTTP GET /users/{p_id}
@authorize admin, user
@cached
@cache_expires_in 300
@rate_limiter_policy standard
';

-- Server-Sent Events for real-time updates
comment on function live_notifications() is '
HTTP
@sse
';

-- File upload with validation
comment on function upload_image(json) is '
HTTP POST
@upload for file_system
@param _meta is upload metadata
@included_mime_types = image/*
';

-- Rate-limited public API
comment on function search(text) is '
HTTP GET /search
@allow_anonymous
@rate_limiter_policy fixed
@validate _query using required
';
Database-First Approach
Static Type Checking End-To-End
Declarative API Design
AI Estimate
55-85%
reduction in API development time across backend and frontend, plus ongoing maintenance savings
Real World Project
~7,300 LOC
lines of code saved with ~57% reduction in codebase size
SQL Functions vs DDD/ORM

Why fight the database when you can embrace it?

Blog



Build, Test, Publish and ReleaseLicenseGitHub StarsGitHub ForksCrafted with Claude

Released under the MIT License.