{"id":48792,"library":"npgsqlrest","title":"NpgsqlRest","description":"Automatic REST API server for PostgreSQL databases that generates REST endpoints from database functions, procedures, tables, and views. Version 3.16.3 (current stable) is actively developed with monthly releases. Key differentiators include AOT-compiled native executables for performance (claimed 6x faster than PostgREST), TypeScript client code generation with end-to-end type safety, declarative configuration via SQL comment annotations, and support for authentication (cookie, JWT, OAuth), authorization, caching, rate limiting, SSE, and OpenAPI 3.0 documentation. Unlike PostgREST or Supabase, NpgsqlRest is a Node.js/npm package that bundles a native binary for Windows, macOS, and Linux.","status":"active","version":"3.16.3","language":"javascript","source_language":"en","source_url":"https://github.com/NpgsqlRest/NpgsqlRest","tags":["javascript","postgresql","server","rest","api","automatic"],"install":[{"cmd":"npm install npgsqlrest","lang":"bash","label":"npm"},{"cmd":"yarn add npgsqlrest","lang":"bash","label":"yarn"},{"cmd":"pnpm add npgsqlrest","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Use npx to run without global install. The npm package downloads a native binary; no JavaScript import is used.","wrong":"npm install -g npgsqlrest && npgsqlrest","symbol":"NpgsqlRest (CLI)","correct":"npx npgsqlrest"},{"note":"The generated client is per-database; you do not import from the package itself.","wrong":"import npgsqlrest from 'npgsqlrest'","symbol":"Auto-generated TypeScript client","correct":"Generated file like ./src/api/{0}Api.ts (import { publicHelloWorld } from './src/api/publicApi')"},{"note":"Config file is in JSON format; CLI supports override flags (e.g., --urls).","wrong":"passing JSON via CLI argument without file","symbol":"Configuration (appsettings.json)","correct":"Create appsettings.json and run npx npgsqlrest"}],"quickstart":{"code":"// 1. Create a PostgreSQL function with annotation\n// CREATE FUNCTION hello_world() RETURNS text LANGUAGE sql AS $$ SELECT 'Hello World' $$;\n// COMMENT ON FUNCTION hello_world() IS 'HTTP GET /hello';\n\n// 2. Create appsettings.json\n// {\n//   \"ConnectionStrings\": {\n//     \"Default\": \"Host=localhost;Port=5432;Database=mydb;Username=postgres;Password=postgres\"\n//   }\n// }\n\n// 3. Run the server\n// npx npgsqlrest\n\n// 4. Test endpoint\n// curl http://localhost:8080/hello\n// => \"Hello World\"","lang":"typescript","description":"Creates a PostgreSQL function with HTTP annotation, configures connection, runs server, and verifies REST endpoint."},"warnings":[{"fix":"Check GitHub releases for native binaries; consider using Docker or building from source.","message":"The package downloads a native binary; it may not be available for all platforms or architectures (e.g., ARM Linux, BSD, 32-bit).","severity":"breaking","affected_versions":">=3.0"},{"fix":"Add SQL comment annotations to functions according to documentation.","message":"The package requires a PostgreSQL database with functions annotated via COMMENT ON FUNCTION IS 'HTTP GET /path'. Without annotations, no endpoints are created.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Migrate to version 3 configuration format: wrap NpgsqlRest-specific options under 'NpgsqlRest' key.","message":"Old configuration files might use a different schema (e.g., without 'NpgsqlRest' section).","severity":"deprecated","affected_versions":"<3.0"},{"fix":"Refer to documentation for all configurable options; use appsettings.json for full control.","message":"The CLI uses .NET configuration; some settings are only available via JSON file, not CLI flags.","severity":"gotcha","affected_versions":">=3.0"}],"env_vars":null,"search_vec":"'/npm':87 '3.0':76 '3.16.3':21 '6x':41 'activ':25 'annot':61 'aot':34 'aot-compil':33 'api':4,103 'authent':65 'author':69 'automat':2,104 'binari':93 'bundl':90 'cach':70 'claim':40 'client':46 'code':47 'comment':60 'compil':35 'configur':57 'cooki':66 'current':22 'databas':8,14 'declar':56 'develop':26 'differenti':31 'document':77 'end':51,53 'end-to-end':50 'endpoint':12 'execut':37 'faster':42 'function':15 'generat':10,48 'includ':32 'javascript':99 'jwt':67 'key':30 'limit':72 'linux':98 'maco':96 'month':28 'nativ':36,92 'node.js':86 'node.js/npm':85 'npgsqlrest':1,82 'oauth':68 'openapi':75 'packag':88 'perform':39 'postgresql':7,100 'postgrest':44,79 'procedur':16 'rate':71 'releas':29 'rest':3,11,102 'safeti':55 'server':5,101 'sql':59 'sse':73 'stabl':23 'supabas':81 'support':63 'tabl':17 'type':54 'typescript':45 'unlik':78 'version':20 'via':58 'view':19 'window':95","created_at":"2026-06-07T16:58:29.361675+00:00","updated_at":"2026-06-07T16:58:29.361675+00:00","problems":[{"fix":"Ensure npm install completed without errors; try reinstalling: npm uninstall npgsqlrest && npm install npgsqlrest. If on ARM, use Docker.","cause":"The native binary is not downloaded properly or platform support is missing.","error":"Could not execute because the application was not found or a matching command is not installed."},{"fix":"Check PostgreSQL is running; verify connection string in appsettings.json; ensure network access.","cause":"Invalid connection string or PostgreSQL not running/accessible.","error":"NpgsqlRest server failed to start: 'Connection refused' or 'FATAL: database does not exist'"},{"fix":"Verify the function exists and has correct comment annotation: COMMENT ON FUNCTION hello_world() IS 'HTTP GET /hello';","cause":"No PostgreSQL function with annotation matching the URL path was created.","error":"GET /hello 404 Not Found"},{"fix":"Update appsettings.json to match the configuration schema for version 3. See documentation.","cause":"Incompatible configuration file schema (e.g., from older version).","error":"MissingMethodException: Method not found: 'Void NpgsqlRest.Configuration.set_SomeOption'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/NpgsqlRest/NpgsqlRest/blob/master/npm/readme.md","github":"https://github.com/NpgsqlRest/NpgsqlRest","docs":null,"changelog":null,"pypi":null,"npm":"npgsqlrest","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}