> ## Documentation Index
> Fetch the complete documentation index at: https://gb.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# REST Commands

### Query parameters

Query parameters are a set of key/value pairs (not case-sensitive):

| **Name** | **Parameter** | **Description**                                                                                                                               |
| -------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| cmd      | c             | c="command" - the type of command, see list below                                                                                             |
| msgType  | mt            | mt="message type" - either the string or numeric label of an SR Data Object class                                                             |
| pkey     | pk            | pk="primary key" - a string representation of the primary key of a specific SR Data Object instance                                           |
| limit    | l             | l="limit" - a number between 1 and 10,000 and acts to limit the number of messages in the response body                                       |
| secret   | secret        | secret="secret" - the client-supplied API Password (if any) \[only used with getapikey]                                                       |
| view     | v             | v="view clause" - a string in the form of "field1 field2 field3"                                                                              |
| where    | w             | w= "where clause" - a string in the form "field1:eq:value" or "(field1:ne:value1 & field1:ne:value2)                                          |
| order    | order         | "(optional) order clause eg. (bidsize:DESC or bidexch:ASC or bidprice:DESC:ABS or askprice:ASC:ABS (default is unordered; default is faster)" |

### Commands

| Command      | Description                                                       | Parameters                               |
| ------------ | ----------------------------------------------------------------- | ---------------------------------------- |
| getapikey    | creates/updates MLink API key                                     | secret                                   |
| getmsgtypes  | returns all available message types                               | view, where                              |
| getschema    | returns a single message schema                                   | msgType, view                            |
| getmsg       | returns a single message by PrimaryKey                            | msgType, pkey, view                      |
| getmsgs      | returns all available messages for a message type                 | msgtype, pkey, limit, view, where, order |
| getaggregate | returns summarized or aggregated data based on specified criteria | msgtype, group, measure                  |
| getcount     | returns the count of records for a message type                   | msgType, where                           |

### Comparison Symbols

"WHERE" clauses can contain the following comparison symbols:

> * :gt: is greater than
> * :ge: is greater than or equal to
> * :lt: is less than
> * :le: is less than or equal to
> * :eq: is equal
> * :ne: is not equal
> * %26 is an AND statement
> * \| is an OR statement
> * :sw: is starts with
> * :ew: is ends with
> * :cv: is contains values
> * :nv: is does not contain value
> * :cb: is contained between (two dates for instance) separated by #

## getAggregate

"getAggregate" takes in both group and measure with a msgType:

* Group types can be the following; examples:

  * Numeric Quantile: `{ "cmd", "getaggregate" }, { "msgtype", "OptionNbboQuote" }, { "group", "bidprice:Q:9" }, { "measure", "bidprice" }`

  * Numeric Range: `{ "cmd", "getaggregate" },{ "msgtype", "OptionNbboQuote" },{ "group", "bidprice:RANGE:3" }, { "measure", "bidprice" }`

  * DateTimeRange: `{ "cmd", "getaggregate" }, { "msgtype", "OptionPrint" },{ "group", $"timestamp:TIMEHIST:3#STARTDATE#ENDDATE" },{ "measure", "prtprice" }`

  * String Top N: `{ "cmd", "getaggregate" }, { "msgtype", "OptionNbboQuote" }, { "group", "bidexch:top:3" }, { "measure", "bidprice|askprice|bidsize|asksize" }`

* You can set measureTypes in group parameters such that: `{ "cmd", "getaggregate" }, { "msgtype", "OptionNbboQuote" }, { "group", "bidexch:top:3:asksize:max" }, { "measure", "bidprice|askprice|bidsize|asksize"}`

Note that measureTypes can be of cnt, min, max, sum, avg
