Advanced Query Parameters
The sTN Partner API supports advanced querying capabilities based on ServiceStack AutoQuery conventions. These allow for complex filtering, sorting, and pagination of results.
Warning
Mind that in the advanced parameters, the phoneNumber key behaves differently than the standard phoneNumber parameter. Whereas the standard parameter accepts both 06-1231212 and 061231212 interchangeably, in the advanced parameters the separating dash is required.
Single Value Condition
- Use the field name directly for single value matching
- Example:
?State=ACTIVE
Multiple Conditions
- Use the
Insuffix for multiple value OR conditions - Example:
?StateIn=ACTIVE,SUSPENDED
- Use the
Comparison Operators
- GreaterThan: Use
GreaterThansuffix - GreaterThanOrEqual: Use
GreaterThanOrEqualsuffix - LessThan: Use
LessThansuffix - LessThanOrEqual: Use
LessThanOrEqualsuffix - Example:
?DataUsageGreaterThanOrEqual=5000
- GreaterThan: Use
Between Queries
- Use
Betweensuffix - Example:
?ActivationDateBetween=2023-01-01,2023-12-31
- Use
Starts With, Ends With, Contains
- Use
StartsWith,EndsWith, orContainssuffix - Examples:
- StartsWith:
?PhoneNumberStartsWith=06- - EndsWith:
?PhoneNumberEndsWith=00 - Contains:
?PhoneNumberContains=123
- StartsWith:
- Use
Combining Queries
- Use
&to combine multiple conditions - Example:
?State=ACTIVE&DataUsageGreaterThanOrEqual=5000&ActivationDateBetween=2023-01-01,2023-12-31
- Use
Pagination and Sorting
- Use
skipandtakefor pagination - Use
orderByfor ascending order sorting - Use
orderByDescfor descending order sorting - Examples:
- Ascending:
?skip=50&take=25&orderBy=ActivationDate - Descending:
?skip=50&take=25&orderByDesc=ActivationDate
- Ascending:
- Multiple sorting criteria can be comma-separated
- Examples:
- Multiple ascending:
?orderBy=State,ActivationDate - Mixed ascending and descending:
?orderBy=State&orderByDesc=ActivationDate
- Multiple ascending:
- Use
Field Selection
- Use
fieldsparameter - Example:
?fields=Id,PhoneNumber,State,DataUsage
- Use
Examples of a Complex Query
Use of 'Between' in query
/api/QuerySubscription?StateIn=ACTIVE,SUSPENDED&ActivationDateBetween=2024-01-01,2024-12-31&PhoneNumberStartsWith=06-&orderBy=State&orderByDesc=ActivationDate&skip=50&take=25&fields=Id,PhoneNumber,StateThis query demonstrates the combination of multiple advanced querying techniques:
- Filtering for ACTIVE or SUSPENDED subscriptions using
StateIn(multiple conditions) - Activated between January 1, 2024, and December 31, 2024
- Phone numbers starting with 06-
- Sorted first by State in ascending order, then by ActivationDate in descending order
- Pagination: skipping the first 50 results and returning the next 25
- Returning only specified fields: Id, PhoneNumber, State
Note: The availability and exact behavior of these query parameters may depend on the specific implementation of the API. Always refer to the most current API documentation for the most accurate information.
Use of other fields in query
It is possible to use other fields (not default fields) in the GET statements. All response fields can be queried. For example if you want to know which SIM's are deactivated on a date, you can use the deActivationDate field from the QuerySubscription API.
/api/QuerySubscription?deActivationDateBetween=2024-12-01,2024-12-07