# API Query Parameters Documentation This is the documentation for the API's query parameters. ## Table of Contents - [Basic Usage](#basic-usage) - [Operators](#operators) - [Sub-Operators](#sub-operators) - [Examples](#examples) ## Basic Usage Query parameters can be added to the API endpoint URL to filter or sort the returned data. The syntax for adding query parameters to a URL is `?parameter1=value1&parameter2=value2...` Multiple query parameters can be used at once by separating them with an `&` symbol. ## Operators There are three operators available for query parameters: - `and`: default operator, returns results that match all conditions - `or`: returns results that match any of the conditions - `not`: returns results that do not match the condition Operators can be specified by adding them before the sub-operator, if any. ## Sub-Operators There are several sub-operators available for query parameters, depending on the data type of the field being filtered. If no sub-operator is specified, `eq` is used by default. ### Numeric Types - `eq`: equal to - `ne`: not equal to - `gt`: greater than - `lt`: less than - `gte`: greater than or equal to - `lte`: less than or equal to - `between`: between two values (use `,` to separate values) ### String Types - `eq`: equal to - `ne`: not equal to - `like`: contains (use `%` as a wildcard) - `notLike`: does not contain (use `%` as a wildcard) ### Array Types - `in`: in the list of values (use `,` to separate values) - `notIn`: not in the list of values (use `,` to separate values) ### Date Types - `eq`: equal to - `neq`: not equal to - `gt`: after - `lt`: before - `gte`: on or after - `lte`: on or before - `between`: between two values (use `,` to separate values) ### Pagination Types - `limit`: limit the number of results (default: 20) - `offset`: offset the results by a certain number #### Example: `/v1/internal/user?limit=10&offset=20` ### How to load relations? use `load` sub-operator to load relations, relation names are the same as the field names in the response - `load`: load relations (use `,` to separate values) #### Example: `/v1/internal/user?load=kyc,settings` ### How to select fields? use `fields` sub-operator to select fields, field names are the same as the field names in the response - `fields:[field1, field2, ...]`: select fields (use `,` to separate values), default is all fields Note: If you are using this operator and preload functionality, you must include the foreign key field in the list of fields to be selected. Most of the time foreign key field is `id`, so including it in field list is enough for relations to load. ### How to sort results? use `sort` sub-operator to sort results, sort fields are the same as the field names in the response - `sort:[asc|desc]`: sort results (use `,` to separate values), default is `asc` #### Example: `/v1/internal/user?sort=price:desc,created_at` ## Examples Here are some examples of query parameter usage: - `/v2/assets/asset?name=BTC-USDT` - returns market `BTC-USDT` - `/v2/assets/asset?name=BTC-USDT&load=baseAsset,quoteAsset` - returns market `BTC-USDT` and load baseAsset and quoteAsset relations - `/v2/assets/asset?name=BTC-USDT&load=baseAsset.networks` - returns market `BTC-USDT` and load baseAsset and baseAsset.networks relations - `/v2/assets/asset?name=like:BTC%` - returns markets that start with `BTC` - `/v2/assets/asset?fields=id,name,baseAsset,price,priceHistory&load=baseAsset&name=like:%-USDT` - returns markets that end with `-USDT` and load baseAsset relation, return only name, baseAsset, price and priceHistory fields.