RPC API

This is a beta feature. Please join the discussion or contact us if you want to contribute.

With release 2108 we introduce RPC API. JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over http, or in many various message passing environments. It uses JSON (RFC 4627) as data format.

Request Formatting

To make a JSON-RPC request, send an HTTP POST request to the [AIDBOX_BASE_URL]/rpc endpoint with a Content-Type: application/json header. The JSON request data should contain 2 fields:

  • method: <string>, a string containing the method to be invoked

  • params: <array>, a JSON object of parameters

Example using curl:

Request
Response (formatted)
Request
curl "$AIDBOX_BASE_URL/rpc" \
-H "Content-Type: application/json" \
-d \
'{
"method": "aidbox/echo",
"params": {
"hello": "world"
}
}'
Response (formatted)
{
"result": {
"hello": "world"
}
}

The response output is a JSON object with one of the following fields:

  • result: <array|number|object|string>, requested data or success confirmation

  • error: <array|number|object|string>

Requests can be sent in batches by sending an array of JSON-RPC request objects as the data for a single POST.