The URL has the following form:
{prefix}/{busname}/{method}[/{arg1}/{arg2}...]
Function defines the purpose of the server. The following functions are defined:
Capabilities define certain features and extensions to the core protocol. The following capabilities are defined:
POST data can be in JSON (cap:JSON) or BSON (cap:BSON) format, the actual format is selected by the Content-Type header. The format of GET data is the same as the format used in /open (JSON or BSON). Sessionless methods (/features, /status, /info) use JSON format.
Purpose: returns functions and capabilities supported by the server and optionally the name and version of the server software.
Arguments: none.
Response:
{
"software": <string>,
"functions": <list>,
"capabilities": <list>
}
Purpose: opens a session, required by subsequent /send, /recv and /stream (cap:STREAM) methods.
Arguments: none
POST input:
{
"cid": <string>,
"heartbeat": <int>,
"recv_limit": <int>,
"queue": {
<queue_name>: {
"topics": <list of string>,
"seq": <int>,
"endseq": <int>,
"starttime": <string>,
"endtime": <string>,
"filter": <doc>,
"qlen": <int>,
"oowait": <int>,
"keep": <bool>
},
...
},
}
Response: HTTP 400 with error message or
{
"queue": {
<queue_name>: {
"seq": <int>,
"error": <string>
},
...
},
"sid": <string>,
"cid": <string>
}
Purpose: returns the status of connected clients (sessions).
Arguments: none.
Response:
{
"session": {
<sid>: {
"cid": <string>,
"address": <string>,
"ctime": <string>,
"sent": <int>,
"received": <int>,
"format": <string>,
"heartbeat": <int>,
"recv_limit": <int>,
"queue": {
<queue_name>: {
"topics": <list of strings>,
"seq": <int>,
"endseq": <int>,
"starttime": <string>,
"endtime": <string>,
"filter": <doc>,
"qlen": <int>,
"oowait": <int>,
"keep": <bool>,
"eof": <bool>
},
...
},
},
...
},
}
The remaining attributes have the same meaning as in /open above.
Purpose: sends a message.
Arguments: /sid
POST input:
{
"type": <string>,
"queue": <string>,
"topic": <string>,
"seq": <int>,
"starttime": <int>,
"endtime": <int>,
"data": <doc>
}
A heartbeat message can be sent to keep an idle session from expiring. The message is otherwise ignored by the server.
{
"type": "HEARTBEAT"
}
JSON and BSON (cap:BSON) formats are supported. Multiple messages can be sent in one /send call; in case of BSON format, multiple messages must be concatenated. In case of JSON format, an array-style document must be sent (even if there is only a single message):
{
"0": <msg>,
"1": <msg>,
...
}
Response: HTTP 400 with error message or HTTP 204.
Purpose: receive a message.
Arguments: /sid[/queue/seq]
If sid is not known to server, HTTP 400 is returned and the client should proceed with /open to create a new session.
If queue/seq does not match queue/seq of last message sent, HTTP 400 is returned and the client should proceed with /open to create a new session. However, if queue/seq does match an earlier object, the server may roll back and continue.
Response: HTTP 400 with error message or
{
"type": <string>,
"queue": <string>,
"topic": <string>,
"sender": <string>,
"seq": <int>,
"starttime": <int>,
"endtime": <int>,
"data": <doc>
}
The remaining attributes have the same meaning as in /post.
Two special values are defined for type:
/recv blocks until at least one message (incl. HEARTBEAT) is available and then returns one or more messages. In case of JSON format, an array-style document is returned (even if the response only contains a single message):
{
"0": <msg>,
"1": <msg>,
...
}
Purpose: returns the list of queues and topics and available data.
Arguments: none.
Response:
{
"queue": {
<queue_name>: {
"startseq": <int>,
"starttime": <string>,
"endseq": <int>,
"endtime": <string>,
"topics": {
<topic>: {
"starttime": <string>,
"endtime": <string>
},
...
},
},
...
},
}
Works like /recv, except that /stream sends an endless stream of messages and never returns. In case of JSON format, an array-style document is returned; since the document has no end, only a progressive JSON parser would be useful.