Skip to content

NpgsqlRestAutomatic PostgreSQL Web Server

Create REST APIs for PostgreSQL databases in minutes.

NpgsqlRest

Example

Let's create a simple function, add comment declration to expose HTTP endpoint that only admin role can call:

sql
create function my_todo(_user text)
returns table (
  what text, 
  who text
)
language sql as $$
select 'Hello World', _user
$$;

comment on function my_todo(text) is '
HTTP GET /hello
authorize admin
';

Automatically generated HTTP file for testing and development:

http
@host=http://localhost:8080

// function public.my_todo(
//     _user text
// )
// returns table(
//     what text,
//     who text
// )
//
// comment on function public.my_todo is 'HTTP GET /hello
// authorize admin';
GET {{host}}/hello?user=ABC

###

Automatically generated TypeScript fetch module with interface declaration that you can import and use in your Frontend project immediately:

typescript
// autogenerated at 2025-08-23T11:09:22.4550472+00:00
import parseQuery from "query";
const baseUrl = "http://localhost:8080";

interface IPublicMyTodoRequest {
    user: string | null;
}

interface IPublicMyTodoResponse {
    what: string | null;
    who: string | null;
}

export const publicMyTodoUrl = (request: IPublicMyTodoRequest) => baseUrl + "/hello" + parseQuery(request);

/**
 * function public.my_todo(
 *     _user text
 * )
 * returns table(
 *     what text,
 *     who text
 * )
 *
 * @remarks
 * comment on function public.my_todo is 'HTTP GET /hello
 * authorize admin';
 *
 * @param {IPublicMyTodoRequest} request
 * @returns {{status: number, response: IPublicMyTodoResponse[] | string}}
 *
 * @see FUNCTION public.my_todo
 */
export async function publicMyTodo(
    request: IPublicMyTodoRequest
) : Promise<{status: number, response: IPublicMyTodoResponse[] | string}> {
    const response = await fetch(publicMyTodoUrl(request), {
        method: "GET",
        headers: {
            "Content-Type": "application/json"
        },
    });
    return {
        status: response.status,
        response: response.status == 200 ? await response.json() as IPublicMyTodoResponse[] : await response.text()
    };
}
Create a working application from your existing PostgreSQL database in seconds...
Just declare what you want.
Focus on what really matters!

Feature List

Instant API GenerationMinimal ConfigurationComment AnnotationsDeclarative ConfigurationHTTP CustomizationAuthentication ControlReal-Time StreamingResponse FormattingJavaScriptTypeScriptHTTP FilesMultiple Auth MethodsEncrypted TokensCORS SupportBuilt-in Password ValidationOAuth IntegrationClaims-based securityRole-Based AuthorizationClaim or Role Parameter MappingClaim or Role Context MappingCSRF ProtectionSSL/TLSPostgreSQL Security and EncryptionHigh PerformanceConnection PoolingKeepAlive, Auto-prepare, Buffer SizeFailover, Load BalancingMultiple ConnectionsConnection RetryThread Pool OptimizationRequest OptimizationResponse CompressionHTTP CachingServer CachingRedis CachingServer-Sent EventsLive NotificationsEvent SourcesRate LimitersCustom ScopesNative ExecutablesContainerizationNPM PackageEnvironment ConfigurationData ProtectionStructured LoggingExcel ProcessingFree And Open SourceUpload HandlersStatic FilesRequest TrackingPerformance MetricsError HandlingCustom HeadersIP TrackingCRUD Support for Tables and View.NET Library Integration And More
Build, Test, Publish and ReleaseLicenseGitHub StarsGitHub Forks

Released under the MIT License.