get_messages
To get messages from the message loader, use the messages/get_messages method. Before that, load messages into the session with messages/load_interval.
Endpoint
svc=messages/get_messages¶ms={
"indexFrom": <uint>,
"indexTo": <uint>,
"timeFrom": <uint>,
"timeTo": <uint>,
"filter": "<text>",
"flags": <uint>,
"flagsMask": <uint>,
"loadCount": <uint>
}
For an example of this request, see Message request examples.
Parameters
The parameters are optional.
| Parameter | Description |
|---|---|
indexFrom |
Index of the first requested message. The default value is 0. |
indexTo |
Index that follows the last requested message: the message with this index isn’t returned. For example, "indexFrom":8,"indexTo":9 returns one message with the index 8. If the value is greater than the number of loaded messages, messages up to the last one are returned. An empty array is returned if indexFrom is equal to or greater than indexTo or the number of loaded messages. |
timeFrom |
Interval beginning. |
timeTo |
Interval end. |
filter |
Filter, search in the pos and p parameters. See Filtering message parameters. |
flags |
Mask applied to the message flags to exclude messages from the response. See Excluding messages by flags. The default value is 0. |
flagsMask |
Value compared with the result of applying flags to the message flags. See Excluding messages by flags. The default value is 0. |
loadCount |
Number of messages to return (0xffffffff means all the found ones). |
The method logic is extended: you can use both the old indexFrom/indexTo logic and the new ones:
| Logic | Description |
|---|---|
timeFrom/timeTo |
Determine the start and end time of the messages. |
timeFrom/loadCount |
Determine the start time of the messages. The method returns the first loadCount messages starting from timeFrom. |
timeTo/loadCount |
Determine the end time of the messages. The method returns the last loadCount messages up to timeTo. |
Important. To use this method, the request should contain at least one of the parameter pairs from above.
Excluding messages by flags
In this method, the flags and flagsMask parameters work differently than in messages/load_interval: they exclude messages from the response instead of selecting them. A message isn’t returned if flags isn’t 0 and the bitwise AND of the message flags (f) and flags equals flagsMask. If flags is 0, no messages are excluded.
flags |
flagsMask |
Excluded messages |
|---|---|---|
| 0xFF00 | 0x0000 | Data messages. |
| 0xFF00 | 0x0600 | Events. |
| 0xFF00 | 0x4000 | Messages about triggered notifications. |
For the message flags, see Messages.
Filtering message parameters
The filter option can be used for any logic. The search is available in the pos and p parameters. The filter doesn’t affect other message fields (for example, t, f, tp, i, o): they’re always returned. If no parameters of the pos object match the filter, pos is returned as an empty object.
Response example (no filtering):
[
{
"t": 1426233861,
"f": 7,
"tp": "ud",
"pos": {
"y": 53.84541,
"x": 27.4470783333,
"z": 0,
"s": 25,
"c": 285,
"sc": 255
},
"i": 0,
"o": 0,
"p": {
"adc1": 0,
"pre2": 123,
"param": 24,
"param5": 43
}
}
]
Filter example:
"filter":"pos.x,p.pre*,p.param?"
Filtered response:
[
{
"t": 1426233861,
"f": 7,
"tp": "ud",
"pos": {
"x": 27.4470783333
},
"i": 0,
"o": 0,
"p": {
"pre2": 123,
"param5": 43
}
}
]
After filtering we see the pos.x value, the values of the parameters in the p object which begin with pre, and the values of the parameters in the p object which begin with param and have one more symbol at the end (for example, param1 is valid, but param is invalid for search).
The number of defined parameters separated by a comma is unlimited. The asterisk (*) is used as a wildcard for 0 or more symbols, and the question mark (?) as a wildcard for one symbol.
Response
[ /* message array */
{ ... }, /* message */
{ ... } /* message */
]
For message formats, see Messages.
Error codes
| Error code | Description |
|---|---|
| 4 | Invalid input parameters (none of the parameter pairs is specified), or no messages are loaded into the session. |