# Model Query API
This document describes the advanced usage functions of TA, including detailed information about multiple technologies, and is a reference for users who are familiar with relevant functions. If you have any questions about this document, please contact your data consultant to obtain one-to-one support.
Model query API is mainly used to get various data analysis reports.
For the description of the call method, please refer to Open API
# I. General Parameters
# Property expression
Almost all APIs would use properties, for example, filtering, grouping, or aggregation based on a certain property. Properties, usually expressed with such two fields as name and table type, can be divided into event properties, user properties, and user cohort properties. For instance, the expression of the event property describing province(#province) is as follows:
{
"tableType":"event",
"columnName":"#province"
}
User properties are similar, e.g., indicating use level(user_level):
{
"tableType":"user",
"columnName":"user_level"
}
# Filter expression
Filtering expression, applicable to most APIs, could be used to describe the filtering operation of certain events or users. JSON expression is as follows:
{
// 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"
]
}]
}
Operators currently supported include:
- equal / notEqual
Means equal to/not equal to, is effective for character strings and numeric types. If there are multiple ftvs, it means In or Not In. For instance, to filter users at level 3 and level 5:
{
"tableType":"user",
"columnName":"user_level",
"comparator": "equal",
"ftv": ["3","5"]
}
- isTrue / isFalse
Only valid for Boolean type.
- isNull / notNull
Whether a property has value. It is effective for string and numeral types.
- include / notInclude
Whether a substring is contained:
{
"tableType":"user",
"columnName":"channel",
"comparator": "include",
"ftv": ["Application treasure "]
}
- Less/greater/range: means less than/greater than/less than and greater than, among which, range is the range between left closed interval and right closed interval, and is valid for numeric type and time type. Here is an example of filtering events with the remaining quantity between 3 and 9:
{
"tableType":"event",
"columnName":"count_left",
"comparator": "range",
"ftv": [3, 9]
}
Or filter all the 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
Regex Match or nonRegexMatch, only valid to string type.
- relativeCurrentBetween / relativeCurrentBefore
Operators for date type indicate that the date is between N days and M days before current time / N days before current time. For example, to filter all the users whose registration time is 3 days before current time:
{
"tableType":"user",
"columnName":"register_time",
"comparator": "relativeCurrentBefore",
"ftv": [3]
}
Or filter all the users whose registration time is 9 days or 3 days before current time:
{
"tableType":"user",
"columnName":"register_time",
"comparator": "relativeCurrentBetween",
"ftv": [9, 3]
}
- relativeEventBefore / relativeEventAfter / relativeEventAbsolute
Operators for date type indicate that the date is within N period of time before the relative event time / within N period of time after the relative event time / within N period of time before or after the relative event time. For instance, to filter events where the previous user login time is within 3 hours before the relative event time:
{
"tableType":"user",
"columnName":"latest_login_time",
"comparator": "relativeEventBefore",
"ftv": [3],
"timeUnit": "hour"
}
- arrayIncludeItem / arrayNotIncludeItem
Operators of list type indicate whether the list contains certain elements.
- arrayItemPos
Operators of list type indicate that the nth element in the list equals to a certain value.
- arrayIsNull / arrayNotNull
Operators of list type indicate whether the list exists.
# Table type enumeration
- event
Event table
- user
User table
- cluster
Cluster/Tag