JSON-RPC API

The JSON-RPC API consists of a single http endpoint. Over which all RPC interaction with the qaul.net daemon happens.

General Concept

The JSON-RPC API's prefix is /rpc. All requests are sent as POST requests to this endpoint and will return with http response code 200.

Request

The general JSON-RPC JSON structure looks like this:

{
    "id": "RANDOM_REQUEST_ID",
    "kind": "MODEL_NAME",
    "method": "METHOD_NAME",
    "data": {
        "field_name": "FIELD_VALUE",
        "field_name": "FIELD_VALUE"
    },
    "auth": {
        "id": "USER_ID",
        "token": "SESSION_TOKEN"
    }
}

The method name can have one of those values:

  • create: When you're creating a new entry.
  • get: To request one entry by ID.
  • modify: To modify an entry.
  • delete: To delete one entry by ID.
  • list: To receive a list of queried entries.

There are some special authentication methods:

  • login: to start an authenticated session
  • logout: to terminate an authenticated session
  • validate: to validate a session token

Request Data Payload

In order to create or modify an entry we send a JSON payload with the request.

To create an entry we send POST a request with the content of some of the fields. Please be aware, that some fields are mandatory and that not all the fields can be set during the creation of an entry. To find out about the specific use please check the documentation of the model.

Create entry payload example:

{
    "field_name": "FIELD_VALUE"
}

To modify and entry we send a PATCH request with only the modified fields in a specific structure. A set structure to set or modify a field, and an unset structure to delete the content of a field.

Modify entry payload example:

{
    "field_name": { "set": "FIELD_VALUE" },
    "field_name": "unset"
}

Response

The general response payload structure looks like this:

{
    "id": "RANDOM_REQUEST_ID",
    "kind": "MODEL_NAME",
    "method": "METHOD_NAME",
    "data": {
        "field_name": "FIELD_VALUE"
    }
}

The "data" field has several specific structures that are documented in the following.

Response Data Payload per Action

The response payloads are model specific and should be checked in the model documentations. however there are some general rules how a payload looks.

When you're requesting a list of entries, you're receiving the following structure:

{
    "id": "RANDOM_REQUEST_ID",
    "kind": "MODEL_NAME",
    "method": "METHOD_NAME",
    "data": {
        "model_name": [
            {
                "id": "ITEM_ID",
                "field_name": "FIELD_CONTENT"
            },
            {
                "id": "ITEM_ID",
                "field_name": "FIELD_CONTENT"
            }
        ]
    }
}

When you get one specific entry by it's ID, or when you create or modify an entry you're receiving the following structure:

{
    "id": "RANDOM_REQUEST_ID",
    "kind": "MODEL_NAME",
    "method": "METHOD_NAME",
    "data": {
        "model_name": {
            "id": "ITEM_ID",
            "field_name": "FIELD_CONTENT"
        }
    }
}

Sometimes you're only receiving a success message as data payload.

{
    "id": "RANDOM_REQUEST_ID",
    "kind": "MODEL_NAME",
    "method": "METHOD_NAME",
    "data": {
        "type": "success"
    }
}

Error Response Data Payload

On error you're receiving an error message as data payload.

{
    "id": "RANDOM_REQUEST_ID",
    "kind": "MODEL_NAME",
    "method": "METHOD_NAME",
    "data": {
        "error": "ERROR_MESSAGE"
    }
}