Skip to content
Written with Claude
IMPORTANT

As you may notice, this page and pretty much the entire website were obviously created with the help of AI. I wonder how you could tell? Was it a big "Written With Claude" badge on every page? I moved it to the top now (with the help of AI of course) to make it even more obvious. There are a few blogposts that were written by me manually, the old-fashioned way, I hope there will be more in the future, and those have a similar "Human Written" badge. This project (not the website), on the other hand, is a very, very different story. It took me more than two years of painstaking and unpaid work in my own free time. A story that, hopefully, I will tell someday. But meanwhile, what would you like me to do? To create a complex documentation website with a bunch of highly technical articles with the help of AI and fake it, to give you an illusion that I also did that manually? Like the half of itnernet is doing at this point? How does that makes any sense? Is that even fair to you? Or maybe to create this website manually, the old-fashioned way, just for you? While working a paid job for a salary, most of you wouldn't even get up in the morning. Would you like me to sing you a song while we're at it? For your personal entertainment? Seriously, get a grip. Do you find this information less valuable because of the way this website was created? I give my best to fix it to keep the information as accurate as possible, and I think it is very accurate at this point. If you find some mistakes, inaccurancies or problems, there is a comment section at the bottom of every page, which I also made with the help of the AI. And I woould very much appreciate if you leave your feedback there. Look, I'm just a guy who likes SQL, that's all. If you don't approve of how this website was constructed and the use of AI tools, I suggest closing this page and never wever coming back. And good riddance. And I would ban your access if I could know how. Thank you for your attention to this matter.

Custom Parameters

Set custom key-value configuration for the endpoint.

Syntax

@<key> = <value>

The @ prefix is optional - both @key = value and key = value work identically. Custom parameters with @ prefix are stored without the prefix (e.g., @my_param = value is stored as my_param).

Dynamic Parameter Values

Some parameters support dynamic values using the {param_name} format, where param_name references a function parameter. The value is resolved at runtime from the actual parameter value passed to the endpoint.

Example

sql
create function upload_file(_path text, _file text)
returns void
language sql as $$
  -- function body
$$;

comment on function upload_file(text, text) is '
@file_system_path = {_path}
@file_system_file = {_file}
';

When called with {"_path": "/uploads/images", "_file": "photo.jpg"}, the file will be saved to /uploads/images/photo.jpg.

Built-in Parameters

The following parameters are recognized by NpgsqlRest and its handlers.

General Parameters

ParameterDescription
buffer_rows, bufferSets the buffered amount of rows before they are written to the response.
columns, names, column_namesIf true and endpoint is in raw mode, response will contain header names.
connection, connection_nameDefines an alternative connection name that must exist in the ConnectionStrings dictionary.
new_line, raw_new_lineDefines the separator between raw value rows when raw mode is enabled.
raw, raw_mode, raw_resultsSets response to raw mode where HTTP response is written exactly as received from PostgreSQL.
separator, raw_separatorDefines the separator between raw value columns when raw mode is enabled.

Upload Handler Parameters

Shared Parameters

ParameterDescription
stop_after_first_successWhen true, stops processing after the first successful upload handler.
included_mime_typesComma-separated list of MIME type patterns to include for upload processing.
excluded_mime_typesComma-separated list of MIME type patterns to exclude from upload processing.

Large Object Upload Handler

ParameterDescription
buffer_size, large_object_buffer_sizeSize of the buffer used for reading/writing large object data.
check_text, large_object_check_textWhen true, checks if the uploaded content is text format.
check_image, large_object_check_imageWhen true, checks if the uploaded content is an image format.
test_buffer_size, large_object_test_buffer_sizeSize of the buffer used for testing file content type.
non_printable_threshold, large_object_non_printable_thresholdThreshold for determining if content contains non-printable characters.
oid, large_object_oidPostgreSQL large object OID to use for storage.
large_object_included_mime_typesMIME type patterns to include for large object upload processing.
large_object_excluded_mime_typesMIME type patterns to exclude from large object upload processing.

File System Upload Handler

ParameterDescription
buffer_size, file_system_buffer_sizeSize of the buffer used for reading/writing file system data.
check_text, file_system_check_textWhen true, checks if the uploaded content is text format.
check_image, file_system_check_imageWhen true, checks if the uploaded content is an image format.
test_buffer_size, file_system_test_buffer_sizeSize of the buffer used for testing file content type.
non_printable_threshold, file_system_non_printable_thresholdThreshold for determining if content contains non-printable characters.
path, file_system_pathFile system path where uploaded files will be stored.
file, file_system_fileSpecific file name to use for the uploaded content.
unique_name, file_system_unique_nameWhen true, generates unique file names to avoid conflicts.
create_path, file_system_create_pathWhen true, creates the directory path if it doesn't exist.
file_system_included_mime_typesMIME type patterns to include for file system upload processing.
file_system_excluded_mime_typesMIME type patterns to exclude from file system upload processing.

CSV Upload Handler

ParameterDescription
test_buffer_size, csv_test_buffer_sizeSize of the buffer used for testing CSV content type.
non_printable_threshold, csv_non_printable_thresholdThreshold for determining if content contains non-printable characters.
check_format, csv_check_formatWhen true, validates the CSV format before processing.
delimiters, csv_delimitersCharacters used as field delimiters in CSV files (e.g., comma, semicolon).
has_fields_enclosed_in_quotes, csv_has_fields_enclosed_in_quotesWhen true, expects CSV fields to be enclosed in quotes.
set_white_space_to_null, csv_set_white_space_to_nullWhen true, converts whitespace-only fields to NULL values.
row_command, csv_row_commandSQL command to execute for each CSV row during processing.
csv_included_mime_typesMIME type patterns to include for CSV upload processing.
csv_excluded_mime_typesMIME type patterns to exclude from CSV upload processing.

Excel Upload Handler

ParameterDescription
sheet_name, excel_sheet_nameName of the specific Excel worksheet to process.
all_sheets, excel_all_sheetsWhen true, processes all worksheets in the Excel file.
time_format, excel_time_formatFormat string for parsing time values from Excel cells.
date_format, excel_date_formatFormat string for parsing date values from Excel cells.
datetime_format, excel_datetime_formatFormat string for parsing datetime values from Excel cells.
row_is_json, excel_row_is_jsonWhen true, treats each Excel row as JSON data.
row_command, excel_row_commandSQL command to execute for each Excel row during processing.
excel_included_mime_typesMIME type patterns to include for Excel upload processing.
excel_excluded_mime_typesMIME type patterns to exclude from Excel upload processing.

SSE (Server-Sent Events) Parameters

SSE Events Path

Additional path appended as a subpath to the main endpoint path for SSE events streaming. If the endpoint path is /path and this value is set to /info, the streaming path will be /path/info. Set to true to use the notice level name as the path.

ParameterValues
sse, sse_path, sse_events_path<path>, true, false

SSE Events Level

Sets the PostgreSQL notice level for SSE events. Determines which PostgreSQL notice messages will be streamed to the client.

ParameterValues
sse_level, sse_events_levelinfo, notice, warning

SSE Events Scope

Scope that determines to whom events are streamed:

ParameterValues
sse_scope, sse_events_scopematching, authorize, all, authorize role1, role2, ...
ScopeDescription
matchingSessions with matching security context of the endpoint initiator.
authorizeOnly authorized sessions receive messages. Optionally specify roles.
allAll sessions regardless of security context receive messages.

TypeScript Client Parameters

ParameterDescription
tsclientSet to false, off, disabled, disable, or 0 to disable TypeScript client code generation for the endpoint.
tsclient_eventsEnable or disable SSE events parameter for endpoints with SSE events enabled.
tsclient_parse_urlEnable or disable URL parsing in generated client.
tsclient_parse_requestEnable or disable request parsing in generated client.
tsclient_status_codeEnable or disable status code in the return value.
tsclient_moduleSets different module name for the generated TypeScript client file.

Comments

Released under the MIT License.