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
In
suffix for multiple value OR conditions - Example:
?StateIn=ACTIVE,SUSPENDED
- Use the
Comparison Operators
- GreaterThan: Use
GreaterThan
suffix - GreaterThanOrEqual: Use
GreaterThanOrEqual
suffix - LessThan: Use
LessThan
suffix - LessThanOrEqual: Use
LessThanOrEqual
suffix - Example:
?DataUsageGreaterThanOrEqual=5000
- GreaterThan: Use
Between Queries
- Use
Between
suffix - Example:
?ActivationDateBetween=2023-01-01,2023-12-31
- Use
Starts With, Ends With, Contains
- Use
StartsWith
,EndsWith
, orContains
suffix - 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
skip
andtake
for pagination - Use
orderBy
for ascending order sorting - Use
orderByDesc
for 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
fields
parameter - 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,State
This 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