sTN Partner APIsTN Partner API
Home
Getting Started
Guide
Home
Getting Started
Guide
  • Guide

    • Introduction
    • Supported Features
    • Authentication
    • Base URLs
    • Advanced Query Parameters
    • Error Handling
  • Getting Started

    • Introduction
    • Quick Start Guide
  • API Endpoints

    • QuerySimcard
    • QueryActivation
    • QuerySubscription
    • NewSubscription
    • CancelNewSubscription
    • SuspendSubscription
    • ResumeSubscription
    • SimSwapSubscription
    • SetServicesSubscription
    • MoveEnvironmentSubscription
    • InPortSubscription
    • ChangeInPortSubscription
    • CancelInPortSubscription
    • PortingOutSubscription
    • CancelPortingOutSubscription
    • TerminateSubscription
    • CancelTerminateSubscription
    • QueryInvoice
    • QueryCdrMonth
    • QueryCdr
    • QueryUsageSubscription

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.

  1. Single Value Condition

    • Use the field name directly for single value matching
    • Example: ?State=ACTIVE
  2. Multiple Conditions

    • Use the In suffix for multiple value OR conditions
    • Example: ?StateIn=ACTIVE,SUSPENDED
  3. Comparison Operators

    • GreaterThan: Use GreaterThan suffix
    • GreaterThanOrEqual: Use GreaterThanOrEqual suffix
    • LessThan: Use LessThan suffix
    • LessThanOrEqual: Use LessThanOrEqual suffix
    • Example: ?DataUsageGreaterThanOrEqual=5000
  4. Between Queries

    • Use Between suffix
    • Example: ?ActivationDateBetween=2023-01-01,2023-12-31
  5. Starts With, Ends With, Contains

    • Use StartsWith, EndsWith, or Contains suffix
    • Examples:
      • StartsWith: ?PhoneNumberStartsWith=06-
      • EndsWith: ?PhoneNumberEndsWith=00
      • Contains: ?PhoneNumberContains=123
  6. Combining Queries

    • Use & to combine multiple conditions
    • Example: ?State=ACTIVE&DataUsageGreaterThanOrEqual=5000&ActivationDateBetween=2023-01-01,2023-12-31
  7. Pagination and Sorting

    • Use skip and take 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
    • Multiple sorting criteria can be comma-separated
    • Examples:
      • Multiple ascending: ?orderBy=State,ActivationDate
      • Mixed ascending and descending: ?orderBy=State&orderByDesc=ActivationDate
  8. Field Selection

    • Use fields parameter
    • Example: ?fields=Id,PhoneNumber,State,DataUsage

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
Last Updated:
Contributors: UP2media-AR
Prev
Base URLs
Next
Error Handling