Sage 200 API Query Parameters
Less than to read
To add query parameters to a request URL, append the question mark character (?) to the URL first. Each query parameter is expressed as a key-value pair, and multiple query parameters must be separated by an ampersand character (&).
The Sage 200 API query parameters follow a subset of the OData standard (see table below). To learn more about the OData Standard, visit http://www.odata.org/ or https://en.wikipedia.org/wiki/Open_Data_Protocol.
Query Parameter | Description |
---|---|
$select |
$select enables you to limit the fields returned within a collection request. This example will only return the id, reference, name, and short_name fields. |
$filter |
$filter returns only the entities that match the criteria set by the specified filter. This example request returns the entities where the value of the reference field is equal to 'ACME01' or the value of the balance field is greater than 1000. Note that clauses are combined with logical operators such as "and" or "or", and values of type string should be in single quotes.
Filters can be applied to date fields. For example:
Note: when including the time, you must specify the UTC timezone (Z at the end as in the example).
Note: value must be inside single quote marks and must be either an int or enum value.
|
$orderby |
$orderby enables you to return a collection in ascending or descending order. The order is based on the specified field name and the keywords asc for ascending and desc for descending. This example orders the results by the short_name field in ascending order. |
$top |
$top returns the maximum number of JSON resources in a request. If the '$orderby' parameter is not specified, then the default is used. When 'top' is not specified, the default value is 500. This example request returns the first 5 JSON resources as a collection. For Sage 200 Standard and versions of Extra/Professional released after February 2019 only: The maximum value that can be specified is 5000. Note: On certain large queries, this can take a long time or even time out. |
$skip |
This feature applies to Sage 200 Standard and versions of Extra/Professional released after July 2017 only:
$skip requests that the number of items in the collection be skipped and not included in the result. The example request returns customers starting with the 26th customer. Note: When using $skip, you must also use the $orderby parameter. Failure to do so will result in an error.</p> |
$expand |
$expand enables you to include child JSON resources that are linked to the parent JSON resource within your results. |
$count |
The $count returns the number of entities within the collection. |
$metadata |
This feature applies to Sage 200 Standard and versions of Extra/Professional released after February 2019 only:
$metadata returns the name, type, sort order, and sort ascending of the fields that can be returned in the request. |
Combining Multiple Commands
It is possible to combine multiple OData commands within a request and create quite complex and insightful results.
For example, you can filter on expanded entities. The following example expands the sales order on the customer but only returns the customer name:
/sop_orders/1388180?$expand=customer&$select=customer.name
The $select
command can also be applied to reduce the fields in both the parent and child entity, like in this example:
/sop_orders/1388180?$expand=customer&$select=id,document_no,customer.id,customer.name
Another example is to retrieve customer emails ordered by id, returning only the top 5:
/customer_emails?$orderby=id&$top=5