Advanced Filtering

Payiano's API provides a powerful and flexible filtering system that allows you to precisely query your data using structured conditions. The filtering capability supports complex logical operations, multiple field types, and nested conditions to meet your specific data retrieval needs.

Tip: Filters are applied to list endpoints through the filters query parameter and follow a consistent JSON structure across all Payiano APIs.

Filter Structure

Payiano's filtering system uses a hierarchical JSON structure that supports complex logical operations. The system is built around two fundamental node types that can be nested to create sophisticated query conditions.

Group Nodes

Container

Logical containers that combine multiple conditions or other groups using AND/OR operators. Groups can be nested to build complex filtering logic.

Condition Nodes

Leaf

Individual filtering rules that specify field comparisons. Each condition defines what data to match using fields, operators, and values.

interface IFilterConditionScalar {
node: 'condition' field: string operator: | 'eq' | 'not_eq' | 'starts_with' | 'not_starts_with' | 'ends_with' | 'not_ends_with' | 'contains' | 'not_contains' value: number | string }
interface IFilterConditionNumeric {
node: 'condition' field: string operator: | 'gt' | 'gte' | 'lt' | 'lte' value: number }
interface IFilterConditionIn {
node: 'condition' field: string operator: 'in' | 'not_in' value: (number | string)[] }
interface IFilterConditionBetween {
node: 'condition' field: string operator: 'between' | 'not_between' value: (number | string)[] }
interface IFilterConditionNull {
node: 'condition' field: string operator: 'is_null' | 'is_not_null' } type FilterCondition = | IFilterConditionScalar | IFilterConditionNumeric | IFilterConditionIn | IFilterConditionBetween | IFilterConditionNull
export interface IFilterGroup {
node: 'group' logic: 'and' | 'or' filters: (FilterCondition | IFilterGroup)[] }

Key Characteristics

Hierarchical Structure

Groups can contain other groups, enabling complex nested logic with unlimited depth.

Type Safety

Operators are validated against field types to prevent invalid queries.

Flexible Logic

Mix AND/OR operators across different nesting levels for precise control.

API Consistency

Same structure works across all Payiano resources - payments, customers, checkouts, etc.

Available Operators

OperatorDescriptionApplicable TypesExample
eqEqual toboolean, date, enum, enum_number, number, reference_id, datetime, ulid, id field = value
not_eqNot equal toboolean, date, enum, enum_number, number, reference_id, datetime, ulid, id field != value
gtGreater thandate, enum_number, number, datetime field > value
gteGreater than or equaldate, enum_number, number, datetime field >= value
ltLess thandate, enum_number, number, datetime field < value
lteLess than or equaldate, enum_number, number, datetime field <= value
starts_withStarts withstring field LIKE "value%"
not_starts_withDoes not start withstring field NOT LIKE "value%"
ends_withEnds withstring field LIKE "%value"
not_ends_withDoes not end withstring field NOT LIKE "%value"
containsContains substringstring field LIKE "%value%"
not_containsDoes not contain substringstring field NOT LIKE "%value%"
inIn list of valuesenum, enum_number, reference_id, ulid, id field IN (value1, value2)
not_inNot in list of valuesenum, enum_number, reference_id, ulid, id field NOT IN (value1, value2)
betweenBetween two values (inclusive)date, enum_number, number, datetime field BETWEEN value1 AND value2
not_betweenNot between two valuesdate, enum_number, number, datetime field NOT BETWEEN value1 AND value2
is_nullIs nullboolean, date, enum, enum_number, number, reference_id, string, datetime, ulid, id
Only applicable to fields that can be null
field IS NULL
is_not_nullIs not nullboolean, date, enum, enum_number, number, reference_id, string, datetime, ulid, id
Only applicable to fields that can be null
field IS NOT NULL

Practical Examples

Basic Filtering

Find payment links with amount greater than or equal to 2000 and status is paid:

1curl "https://api.payiano.com/v1/payment/payment_links?filters[node]=group&filters[logic]=and&filters[filters][0][node]=condition&filters[filters][0][field]=payment_details.amount&filters[filters][0][operator]=gte&filters[filters][0][value]=2000&filters[filters][1][node]=condition&filters[filters][1][field]=payment_details.status&filters[filters][1][operator]=eq&filters[filters][1][value]=paid" \ 2 -H "Authorization: Bearer ACCESS-TOKEN"
{
"node": "group", "logic": "and",
"filters": [
{
"node": "condition", "field": "payment_details.amount", "operator": "gte", "value": 2000 },
{
"node": "condition", "field": "payment_details.status", "operator": "eq", "value": "paid" } ] }

Complex AND/OR Logical Groups

Find payment links that meet any of the following: have an amount greater than or equal to 2000, are either paid or pending, or are assigned to a customer, and were created between January 1, 2024, and December 31, 2024.

1curl "https://api.payiano.com/v1/payment/payment_links?filters[node]=group&filters[logic]=and&filters[filters][0][node]=group&filters[filters][0][logic]=or&filters[filters][0][filters][0][node]=condition&filters[filters][0][filters][0][field]=payment_details.amount&filters[filters][0][filters][0][operator]=gte&filters[filters][0][filters][0][value]=2000&filters[filters][0][filters][1][node]=condition&filters[filters][0][filters][1][field]=payment_details.status&filters[filters][0][filters][1][operator]=in&filters[filters][0][filters][1][value][0]=pending&filters[filters][0][filters][1][value][1]=paid&filters[filters][0][filters][2][node]=condition&filters[filters][0][filters][2][field]=customer_id&filters[filters][0][filters][2][operator]=is_not_null&filters[filters][1][node]=condition&filters[filters][1][field]=created_at&filters[filters][1][operator]=between&filters[filters][1][value][0]=2024-01-01&filters[filters][1][value][1]=2024-12-31" \ 2 -H "Authorization: Bearer ACCESS-TOKEN"
{
"node": "group", "logic": "and",
"filters": [
{
"node": "group", "logic": "or",
"filters": [
{
"node": "condition", "field": "payment_details.amount", "operator": "gte", "value": 2000 },
{
"node": "condition", "field": "payment_details.status", "operator": "in",
"value": [
"pending", "paid" ] },
{
"node": "condition", "field": "customer_id", "operator": "is_not_null" } ] },
{
"node": "condition", "field": "created_at", "operator": "between",
"value": [
"2024-01-01", "2024-12-31" ] } ] }