# Model Query API
The content described in this document belongs to the advanced use functions of TA, involving more technical details, and is suitable for users with experience in related functions. If you have doubts about the content of the doc, please consult your data consultant for one-on-one assistance.
The Model Query API is primarily used to obtain various data analytics reports.
See Invoke method description in Open API doc.
# I. General Parameters
# Attribute Expression
Almost all APIs use attributes, such as filtering, grouping, or aggregating by an attribute. Attributes include event attributes, user features, and user grouping attributes. Attributes are usually expressed in two fields: name and table type. For example, the expression for this event attribute, Province, is as follows:
{
"tableType":"event",
"columnName":"#province"
}
The user features are similar, for example, indicating that the user level:
{
"tableType":"user",
"columnName":"user_level"
}
# Filter Expression
Filter expressions are also applicable to most APIs and are used to represent filtering operations on certain events or users, using JSON in the following format:
{
// Indicates whether the conditions in filters are'or'or'and'.
"relation": "and",
// Specific condition list, you can have more than one
"filts": [{
// The left value of the condition is an attribute
"tableType":"event",
"columnName": "#os",
// A comparator of conditions, which means equal to
"comparator": "equal",
// A comparison value of a condition that can have one or more comparisons depending on the comparator
"ftv": [
"ios"
]
},
{
"tableType":"user",
"columnName":"user_level",
"comparator": "equal",
"ftv": [
"5"
]
}]
}
The currently supported operators are as follows:
- equal / notEqual
Means equal to/not equal to, valid for string and numeric types. If there are multiple ftv, it is equivalent to In or Not In. For example, if you want to filter out users with levels 3 and 4:
{
"tableType":"user",
"columnName":"user_level",
"comparator": "equal",
"ftv": ["3","5"]
}
- isTrue / isFalse
Valid only for Boolean types.
- isNull / notNull
Whether a property has a value is valid for string and numeric types.
- include / notInclude
Indicates whether a substring is included or not:
{
"tableType":"user",
"columnName":"channel",
"comparator": "include",
"ftv": ["Application treasure "]
}
- Less/greater/range: means less than/greater than/less than and greater than, where range is a closed interval, and the logarithmic value type and time type are valid. For example, filter all events where the remaining number of items is between 3 and 9:
{
"tableType":"event",
"columnName":"count_left",
"comparator": "range",
"ftv": [3, 9]
}
Or filter all users whose last login time is between 2019-11-13 00:00 and 2019-11-23 00:00
{
"tableType":"user",
"columnName":"latest_login_time",
"comparator": "range",
"ftv":["2019-11-13 00:00","2019-11-23 00:00"]
}
- regexMatch / notRegexMatch
Regular match or regular mismatch, valid only for string types.
- relativeCurrentBetween / relativeCurrentBefore
Operators for date types, respectively, indicate that the relative current time is between the past N days and the past M days/the relative current time is before the past N days. For example, I want to filter all users whose registration time is 3 days before the current time:
{
"tableType":"user",
"columnName":"register_time",
"comparator": "relativeCurrentBefore",
"ftv": [3]
}
Or filter all users whose registration time is between the past 9 days and the past 3 days relative to the current time:
{
"tableType":"user",
"columnName":"register_time",
"comparator": "relativeCurrentBetween",
"ftv": [9, 3]
}
- relativeEventBefore / relativeEventAfter / relativeEventAbsolute
For the date type operator, respectively, the relative event occurrence time within N long time before/relative event occurrence time within N long time after/relative event occurrence time within N long time before and after. For example, I want to filter the events within 3 hours before the user's last login time relative to the event occurrence time:
{
"tableType":"user",
"columnName":"latest_login_time",
"comparator": "relativeEventBefore",
"ftv": [3],
"timeUnit": "hour"
}
- arrayIncludeItem / arrayNotIncludeItem
List type operator indicating whether the list contains some elements.
- arrayItemPos
List type operator indicating that the nth element of the list is equal to a value.
- arrayIsNull / arrayNotNull
List type operator, indicating whether the list exists.