# 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:** ```bash 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:** ```bash 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:** ```bash 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:** ```bash 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:** ```bash 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:** ```bash 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:** ```bash curl -X POST http://localhost:8080 \ -H "Content-Type: application/json" \ -d '{"jsonrpc": "2.0", "method": "herodb_getServerStats", "id": 1}'