JSON-RPC 2.0 over WebSocket.
From 15.1, FreeCORE accepts JSON-RPC 2.0 over WebSocket in addition to the message-based WebSocket protocol inherited from TrueNAS® CORE 13.3.
Use it to connect third-party tooling that speaks JSON-RPC 2.0, such as
monitoring applications. The existing protocol is unchanged. The FreeCORE web
interface, midclt and existing clients keep speaking it.
Endpoints
Section titled “Endpoints”| Endpoint | Protocol |
|---|---|
wss://<system>/api/current |
JSON-RPC 2.0 from the first frame. |
wss://<system>/websocket |
The inherited protocol, or JSON-RPC if the first frame is a JSON-RPC request. |
Point a JSON-RPC client at /api/current. The autodetection on /websocket
exists so that a client that only knows the older path still works.
Authenticate
Section titled “Authenticate”Call an authentication method before anything else. FreeCORE accepts:
auth.login_with_api_key: An API key created under Settings › API Keys.auth.login: A user name and password.auth.token: An existing session token.
{"jsonrpc": "2.0", "id": 1, "method": "auth.login_with_api_key", "params": ["<api key>"]}A successful reply carries "result": true. Any other call before
authentication returns an error rather than data.
FreeCORE does not provide auth.login_ex. A client that requires it
cannot be supported by configuration. It needs a fallback to one of the methods
above.
Call a Method
Section titled “Call a Method”{"jsonrpc": "2.0", "id": 2, "method": "system.info", "params": []}Method names, parameters and results are FreeCORE’s own. They are the same ones the inherited protocol and the REST API expose. This feature is protocol compatibility, not API parity with a different product. A method that FreeCORE does not implement is not reachable over JSON-RPC either.
Note
Only positional parameters are accepted. params must be an array or
absent. An object is rejected with -32602.
Batch requests are not supported. An array at the top level is rejected with
-32600.
Subscribe to Events
Section titled “Subscribe to Events”{"jsonrpc": "2.0", "id": 3, "method": "core.subscribe", "params": ["reporting.realtime"]}The server then sends collection_update notifications until the client calls
core.unsubscribe with the subscription id returned by core.subscribe.
core.set_options is also available.
Errors
Section titled “Errors”Standard JSON-RPC codes are used for protocol problems: -32700 invalid JSON,
-32600 invalid request, -32601 unknown method, -32602 invalid parameters,
-32603 internal error.
Two implementation-defined codes carry the rest:
| Code | Meaning |
|---|---|
-32000 |
Too many concurrent calls on this connection. |
-32001 |
The method itself raised an error. The data member carries the error number the inherited protocol would have reported. |
See API Reference for more information on the FreeCORE API.
Previous
API ReferenceNext
Releases