Filter Query Parameter

Filtering provides options to customize the data in the response based on the selected criteria. You can filter the data displayed in API responses using Gotransverse API Query Language. The syntax of the API query language is similar to SQL. The criteria are expressed in the form of predicates in the following format:

“<query parameter> <comparison operator> ‘<constant>’”

Filtering

  1. The name of the available query parameter. For example, billing_account_id or bill_cycle_type.

  2. The comparison operator such as EQ (equals) or GT (greater than).

  3. The constant value in single quotes ('sample'). Parentheses are used to group predicates in complex clauses. For example, (start_date GT '2021-01-24T23:33:07+00:00').

To create the desired query, combine query parameters available for the endpoint with the comparison and logical operators.

Comparison Operators

Comparison operators are used to filter the response data by evaluating it against the specified filter criteria. For example, you can obtain only billing accounts with USD set as the default currency by using the currency_code query parameter followed by the EQ (equals) comparison operator and the ‘USD’ filter value:

GET /billing-accounts?filter=currency_code EQ 'USD'.

Gotransverse API Query Language supports the following comparison operators:

  • NEQ — Not Equal.

  • EQ — Equals.

  • LT — Less Than.

  • LTE — Less Than or Equal.

  • GT — Greater Than.

  • GTE — Greater Than or Equal.

  • IS NULL — Is set to NULL.

  • IS NOT NULL — Is not set to NULL.

  • LIKE — Matches the pattern specified by the following wildcard characters:

    • %: Any number of characters, including no characters.

    • _: Exactly one character. The LIKE operator only applies to parameters of the string type.

  • IN — TRUE if the query parameter is equal to one of an enumeration. It can have a maximum of 50 enumerations per query parameter. The maximum number of IN operators in one request is 10.

Logical Operators

Logical operators like OR are used to connect two or more filter expressions in order to customize the response data based on multiple conditions. For example, with logical operators, you can select either Suspended or Active bill cycles in one request:

GET /bill-cycles?filter=(status EQ 'SUSPENDED') OR (status EQ 'ACTIVE').

Refer to Filtering Use Cases for more examples.

Gotransverse API Query Language supports the following logical operators:

  • AND — Conjunction.

  • OR — Disjunction.

  • NOT — Negation.

Gotransverse does not adopt SQL to full extend.