When connecting with the OData Connector, you have the option to modify the request. When using the REST-API, there are certain parameters you can use. This article contains all options.
Select
To filter which fields to retrieve, you can use the $select parameter.
https://odata.bluevi.com/api.rsc/your_endpoint?$select=id,name,updated_at
This call will only retrieve the fields id, name and updated at.
Filter
You can use the $filter parameter to filter records. The following operators are supported:
Operator | Meaning |
---|---|
eq | Equal |
ne | Not Equal |
gt | Greater than |
ge | Greater than or Equal |
lt | Less than |
le | Less than or Equal |
not | Negation |
To retrieve all records with an id bigger than 1,000,000, you can use the following.
https://odata.bluevi.com/api.rsc/your_endpoint?$filter=id gt 10000000
Count
To find out how many records a table contains, you can use the $count parameter.
https://odata.bluevi.com/api.rsc/your_endpoint?$count=true
The response will then contain the following value: "@odata.count": AMOUNT_OF_ROWS
Orderby
To sort the data, you can use the $orderby parameter
https://odata.bluevi.com/api.rsc/your_endpoint?$orderby=id asc
This will sort the data by id in ascending order.
Sorting options are asc and desc. If no keyword is indicated, the sorting will be ascending.
Top (limit)
To only fetch a limited amount of records, you can use the $top parameter.
https://odata.bluevi.com/api.rsc/your_endpoint?$top=1000
This will only return the first 1000 records. Combining with the $orderby will give the first 1000 or the last 1000 records, depending on your sort settings.
https://odata.bluevi.com/api.rsc/your_endpoint?$top=1000&$orderby=id desc
Skip (offset)
To skip a number of rows, you can use the $skip parameter.
https://odata.bluevi.com/api.rsc/your_endpoint?$skip=1000
This will skip the first 1000 records.
Pagination
If you want to use pagination in your api calls (which is recommended when data exceeds 100.000 records), you can use pagination by combining the $top and $skip parameters.
When implementing pagination, it is required to also use the $orderby.
https://odata.bluevi.com/api.rsc/your_endpoint?$skip=1000&$top=100&$orderby=id
This query will return the first 100 rows after skipping 1000 rows, so rows 1001 up until row 1100.