pg_deribit
pg_deribit · SQL wrapper for Deribit public and authenticated JSON-RPC APIs
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102027 | pg_deribit | pg_deribit | 1.0 | FEAT | MIT | SQL |
PostgreSQL · 17
| Relationships | |
|---|---|
| Requires | pgcrypto omni_http omni_httpc |
Usage
Sources:
- README.md
- pg_deribit.control
- Makefile
- Dockerfile
- sql/functions/environment.sql
- sql/functions/auth.sql
- sql/functions/internal_url_endpoint.sql
- sql/endpoints/public_get_currencies.sql
pg_deribit 1.0 exposes Deribit JSON-RPC endpoints through SQL. It requires the Omnigres HTTP extensions; the upstream container uses PostgreSQL 17. Public calls can read market metadata, while authenticated endpoints can perform account operations.
Public Testnet Workflow
Dependencies and Configuration
The non-relocatable extension uses the deribit schema and requires pgcrypto, omni_http and omni_httpc. Installation uses the default superuser restriction. It contains SQL functions and types, with no extension-specific shared library or preload setting. The dependencies must be installed and usable.
Production is the default endpoint. deribit.enable_test_net() and deribit.disable_test_net() change deribit.set_test_net for the current session; enable testnet again in each fresh connection. Calls need outbound network access and depend on the remote API.
Authenticated Calls
deribit.set_client_auth(client_id, client_secret) and deribit.set_access_token_auth(client_id, client_secret, access_token, refresh_token) set session credentials; deribit.get_auth() reads them. Grant SQL access deliberately and keep credentials out of query logs and shared examples. Private wrappers include account-changing operations: a database transaction rollback does not undo an already completed remote action. Review individual endpoint signatures before granting access.
Credentials are stored in session settings. The upstream setters interpolate values with %s instead of SQL-literal quoting, so never pass untrusted credential strings. Functions retain default PUBLIC execution permissions; restrict them for your deployment. Private request/response data is persisted in deribit.internal_archive and needs an explicit retention policy.