Working with List Endpoints¶
This guide explains how to effectively use list endpoints in Transact API. All list endpoints in this API follow a consistent pattern, allowing for efficient querying, filtering, and sorting of data.
Basic Structure¶
A typical request to a list endpoint looks like this:
Where {resource} is the name of the resource you're querying (e.g., ppex/orders, parties, accounts, links, trades etc.).
Query Parameters¶
List endpoints support the following query parameters:
limit: Number of records to returnoffset: Number of records to skip before starting to return resultsfilter: Conditions to filter the resultssort: Field(s) and direction to sort the results
Pagination¶
Use limit and offset for pagination:
This returns 10 records, starting from the 21st record.
Sorting¶
Use the sort parameter to specify the field and direction for sorting:
Use :asc for ascending order and :desc for descending order.
Filtering¶
The filter parameter allows you to specify conditions for the returned data. You can use simple filters, array filters, and range filters.
-
Simple filter (exact match):
-
Array filter (IN clause):
-
Range filter:
For range filters, you can specify inclusivity:
GET /v3/{resource}?filter[fieldName][min]=minValue&filter[fieldName][max]=maxValue&filter[fieldName][min_inclusive]=false&filter[fieldName][max_inclusive]=false
By default, ranges are inclusive. Use min_inclusive=false or max_inclusive=false to make them exclusive. This works well for date ranges where you want to get all records that were created on a particular day.
GET /v3/ppex/orders?filter[updatedDate][min]=1999-01-22&filter[updatedDate][max]=1999-01-23&filter[updatedDate][max_inclusive]=false
This will retrieve only records that were updated on January 22, 1999. You can also get records from a particular hour of the day:
GET /v3/ppex/orders?filter[updatedDate][min]=1999-01-22T10:00:00-0500&filter[updatedDate][max]=1999-01-22T11:00:00-0500&filter[updatedDate][max_inclusive]=false
This will retrieve only records that occurred during the 10 'o'clock hour Eastern Standard Time.
- Multiple filters:
Multiple filters are combined with AND logic.
- Filters can also be defined using JSON syntax:
GET /v3/{resource}?filter={"fieldName": "value"}
GET /v3/{resource}?filter={"field1": "value1", "field2":{"min":minValue, "max": maxValue, "maxInclusive": false}
Advanced Filtering¶
Transact API supports advanced filtering options, allowing for more complex and precise data queries. You can use various operators to filter your results based on different conditions.
Filter Operators¶
The following operators are now available for filtering:
eq: Equal tone: Not equal togt: Greater thangte: Greater than or equal tolt: Less thanlte: Less than or equal toin: In a list of valuesnin: Not in a list of valueslike: Pattern matching (using SQL LIKE syntax)between: Between two values (inclusive)
Using Advanced Filters¶
To use these advanced filters, you can specify them in the filter parameter using JSON syntax. Here are some examples:
-
Equal to:
-
Not equal to:
-
Greater than:
-
Less than or equal to:
-
In a list of values:
-
Pattern matching:
-
Between two values:
Combining Multiple Filters¶
You can combine multiple filters in a single query. The filters will be applied with AND logic:
GET /v3/{resource}?filter={"field1": {"gt": 100}, "field2": {"in": ["A", "B"]}, "field3": {"like": "%test%"}}
This query will return results where field1 is greater than 100 AND field2 is either "A" or "B" AND field3 contains the word "test".
Range Filters¶
The existing range filter syntax is still supported and works as before:
GET /v3/{resource}?filter={"fieldName": {"min": minValue, "max": maxValue, "min_inclusive": true, "max_inclusive": false}}
Data Type Handling¶
The API automatically handles data type conversion for date/time and numeric values:
- Date/time values are converted to the format "YYYY-MM-DD HH:MM:SS"
- Numeric values are converted to floating-point numbers
Error Handling¶
If an invalid filter is provided, the API will return a 422 error with the description "invalid filter". Always ensure that your filter syntax is correct and that you're using valid field names and operators.
Response Format¶
List endpoints typically return responses in this format:
{
"statusCode": "101",
"statusDesc": "Ok",
"data": [
{
// Resource-specific fields
},
// More items...
],
"pagination": {
"totalRecords": number,
"startIndex": number,
"endIndex": number
}
}
Tips and Best Practices¶
- Start with a small
limitto test your query before requesting larger datasets. - Use filters to reduce the amount of data transferred and processed.
- When using date or numeric ranges, the API automatically converts values to the appropriate format.
- Combine filters and sorting to get precisely the data you need.
- Pay attention to the
paginationobject in the response to handle large datasets effectively.
Error Handling¶
If your request is invalid or an error occurs, the API will return an appropriate error code and description. Always check the statusCode and statusDesc in the response. The API implements robust error handling to provide clear feedback on request issues. Here are common error scenarios:
- Invalid Pagination Parameters:
- If
offsetorlimitis not a valid integer, you'll receive a 422 error with code "1422" and a description explaining the issue. - If
limitis out of the allowed range (1 to 500), you'll get a 422 error with code "239" and a description of the valid range. -
If
offsetis negative or exceeds the total number of records, you'll receive a 422 error with code "239" and a description of the valid range. Note that for empty result sets, even an offset of 0 will trigger this error, as it technically exceeds the total number of records (which is 0). -
Invalid Filter:
- If the
filterparameter cannot be decoded (for JSON-encoded filters), you'll get a 400 error. -
If the filter contains invalid fields or values, you'll receive a 422 error with a description "invalid filter".
-
Authorization Issues:
-
If the required scopes are not granted, you'll get a 403 error with the description "permission denied".
-
General Errors:
- Other errors will return appropriate HTTP status codes (e.g., 400 for bad requests, 500 for server errors) with a descriptive message.
Error responses follow this general structure:
This guide provides a general overview of working with list endpoints in Transact API. For specific details about individual endpoints, please refer to the dedicated documentation for each resource.