Files
herodb/RPC_COMMANDS.md
Maxime Van Hees 052cf2ecdb update RPC docs
2025-09-10 16:34:01 +02:00

2.6 KiB

HeroDB RPC Commands

HeroDB provides a JSON-RPC 2.0 interface for database management operations. The RPC server runs on a separate port (default 8080) and can be enabled with the --enable-rpc flag.

All RPC methods are prefixed with the namespace herodb. With the exception fo the rpc.discover call (using the rpc namespace), which returns the OpenRPC spec.

Available Commands

herodb_listDatabases

Lists all database indices that exist.

Example:

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "herodb_listDatabases", "id": 1}'

herodb_createDatabase

Creates a new database at the specified index.

Parameters:

  • db_index (number): Database index to create

Example:

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "herodb_createDatabase", "params": [1], "id": 1}'

herodb_getDatabaseInfo

Retrieves detailed information about a specific database.

Parameters:

  • db_index (number): Database index

Example:

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "herodb_getDatabaseInfo", "params": [0], "id": 1}'

herodb_configureDatabase

Configures an existing database with specific settings.

Parameters:

  • db_index (number): Database index
  • config (object): Configuration object

Example:

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "herodb_configureDatabase", "params": [0, {"name": "test", "max_size": 1048576}], "id": 1}'

herodb_setDatabaseEncryption

Sets encryption for a specific database index.

Parameters:

  • db_index (number): Database index
  • encryption_key (string): Encryption key

Example:

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "herodb_setDatabaseEncryption", "params": [10, "my-secret-key"], "id": 1}'

herodb_deleteDatabase

Deletes a database and its files.

Parameters:

  • db_index (number): Database index to delete

Example:

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "herodb_deleteDatabase", "params": [1], "id": 1}'

herodb_getServerStats

Retrieves server statistics.

Example:

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "herodb_getServerStats", "id": 1}'