Automatic REST API Server for PostgreSQL
Transform your PostgreSQL database into a production-ready REST API server with automatic TypeScript code generation and end-to-end type safety.
Documentation | Getting Started | Configuration Reference | Annotation Guide
- Instant API Generation - Automatically creates REST endpoints from PostgreSQL functions, procedures, tables, and views
- Declarative Configuration - Configure endpoints directly in your database using comment annotations
- TypeScript Code Generation - Auto-generate type-safe frontend code with full static type checking
- Native Executables - AOT-compiled binaries with zero dependencies and instant startup
- RESTful Path Parameters - Define routes like
/products/{id}with parameters extracted from URL paths - Reverse Proxy Endpoints - Forward requests to upstream services with passthrough or transform modes
- HTTP Custom Types - Enable PostgreSQL functions to call external APIs via annotated composite types
- Enterprise Ready - Authentication, authorization, rate limiting, caching, SSE streaming, OpenAPI 3.0, and more
create function hello(_name text)
returns text
language sql as $$
select 'Hello, ' || _name
$$;
comment on function hello(text) is 'HTTP GET /hello';Create appsettings.json:
{
"ConnectionStrings": {
"Default": "Host=localhost;Port=5432;Database=my_db;Username=postgres;Password=postgres"
}
}# Download from releases, or:
npm i npgsqlrest && npx npgsqlrest
# Or with Docker:
docker run -p 8080:8080 -v ./appsettings.json:/app/appsettings.json vbilopav/npgsqlrest:latestYour API is now live at http://localhost:8080/hello?name=World
| Method | Command |
|---|---|
| NPM | npm i npgsqlrest |
| Docker | docker pull vbilopav/npgsqlrest:latest |
| Direct Download | Releases |
| .NET Library | dotnet add package NpgsqlRest |
- PostgreSQL >= 13
- No runtime dependencies for native executables
For complete documentation including configuration options, authentication setup, TypeScript generation, and more, visit npgsqlrest.github.io
Contributions are welcome. Please open a pull request with a description of your changes.
MIT License