Sorting
The Data Stream can be sorted by any column in ascending or descending order. Sorting by multiple columns at once is also possible.
Sorting
GET
https://api.fusionbase.com/api/v2/stream/data/{STREAM_ID}?query_parameters={"sort_order": ["asc"], "sort_keys": ["fb_datetime"]}&format=json
The Data Stream can be sorted by any column in ascending or descending order. Sorting by multiple columns at once is also possible.
Path Parameters
Name | Type | Description |
---|---|---|
STREAM_ID | String | The ID of the Data Stream |
Query Parameters
Name | Type | Description |
---|---|---|
query_parameters | Object | URI encoded JSON string |
format | String | json or msgpack |
This is a sample response for a specific stream:
Overview
The Fusionbase API allows users to sort data within a stream using the query_parameters
parameter in the request. This feature enables efficient organization and retrieval of data based on specific sorting criteria.
Sorting Data in a Stream
Request Structure
To sort data in a stream, include the query_parameters
parameter in your GET request to /api/v2/stream/data/{STREAM_ID}
. This parameter accepts JSON-formatted sorting instructions.
Sorting Properties
The query_parameters
JSON object can contain the following properties related to sorting:
sort_keys
: A list of column names by which the data should be sorted. These keys should correspond to columns in the data stream.sort_order
: Specifies the sorting order for each key insort_keys
. The available options are"asc"
for ascending order and"desc"
for descending order.
Multiple Sorting Keys
You can specify multiple sort keys in the sort_keys
list. The data will be sorted based on the order of keys provided. The corresponding sort_order
list should match the length of sort_keys
to specify the sorting order for each key.
Example
Consider a data stream with columns such as fb_datetime
, price
, and product_name
. To sort the data first by fb_datetime
in ascending order and then by price
in descending order, structure your request as follows:
Note
The sorting functionality is dependent on the structure of the data stream.
Ensure that the column names used in
sort_keys
are valid and present in the data stream.The order of elements in
sort_keys
andsort_order
is significant and should correspond to each other.
Error Handling
If invalid column names are used or if there's a mismatch in the length of sort_keys
and sort_order
, the API might return an error response.
Last updated