OkayAPI Docs


API Path: /api/App/SuperTable/FreeAggregation

API Description: RStat Perform aggregation operations such as SUM/COUNT/MIN/MAX/AVG based on multiple customized conditions (AND or OR), and supports aggregation operations on multiple fields.

3
API Traffic
HTTP/HTTPS
Protocol
GET/POST
Method
UTF-8
Charset
JSON
Response

API Debug   


API Params

ParameterTypeRequiredDefaultNoteDescription
HTTP_APPKEYStringRequiredMIN: 32Common Put Your APPKEY
model_nameStringRequired数据库表名
databaseStringOptaionsuper自己的数据库配置标记,注意!这是数据库的配置标识,不是数据库的名称。默认使用super,不用传。如果需要配置多个数据库时,可与小白技术人员联系。重要事情说三遍,这是数据配置标识,不是数据库名称。使用此接口前,请先进入:数据库直连服务配置
op_funsArraySeperated with ,RequiredMIN: 1聚合函数操作,支持多个聚合运算,目前支持:SUM/COUNT/MIN/MAX/AVG,分别表示:求和/数目/最小/最大/平均数,注意全部大写,多个用英文逗号分割。
op_fieldsArraySeperated with ,Required进行聚合的字段名称,需要和op_funs的运算一一对应,,多个用英文逗号分割。例如:假设op_funs=SUM,COUNT,同时op_fields=price,id,那么最终相当于:SUM(price), COUNT(id),返回结果字段是:SUM_price, COUNT_id
logicEnumOptaionandRange: and/orWhere condition logic, logic=and for logical and, logic=or for logical or
whereArrayJSON FormatOptaion[["id", ">=", "1"]]SQL WHERE condition, JSON format: [condition_1, condition_2, ...]

EACH condition: ["FIELD", "OP", "COMPARE_VALUE"]
  • FIELD: Table field name;
  • OP: such as >、>=、<、<=、<>、!=、EQ、GT、GE、LT、LE、NE、LIKE、NLIKE、IN、NIN、BETWEEN、NBETWEEN
  • COMPARE_VALUE: The values that need to be compared, the format of the comparison value will be different. If the field is a numeric type, pass the numeric type, not a string.
Example: logic=and, where=[["id",">",9],["id","<=",10]], It means: id > 9 AND id <= 10
where_XStringOptaion动态条件,优先于where的JSON数据,简化的where条件,更易使用但只支持部分比较符。条件格式:where_ + X(X要换成你的字段名) = 比较符(见下方) + 中横线(-) + 比较值。支持的比较符和示例如下:
  • EQ:等于(默认),如:where_year=EQ-2020,或:where_year=2020,表示年份year等于2020;
  • GT:大于,如:where_year=GT-2020,表示年份year大于2020;
  • GE:大于等于,如:where_year=GE-2020,表示年份year大于或等于2020;
  • LT:小于,如:where_year=LT-2020,表示年份year小于2020;
  • LE:大于等于,如:where_year=LE-2020,表示年份year小于或等于2020;
  • NE:不等于,如:where_year=NE-2020,表示年份year不等于2020;
  • LIKE:模糊匹配,如:where_name=LIKE-小白,表示名字name含有小白的;
  • NLIKE:模糊匹配(排除),如:where_name=NLIKE-小白,表示名字name不包含小白的
  • IN:枚举查询,如:where_year=IN-2020,2021,2022,表示年份year在这三个年份,多个值用英文逗号分割
  • NIN:枚举查询(排除),如:where_year=NIN-2020,2021,2022,表示年份year不在这三个年份,多个值用英文逗号分割
如果同一字段有多个条件,使用双竖线||分割,如:where_year=GT-2000||LT-2020,表示year年份大于2020(logic=and或logic=or)小于2020。(where和where_X二选一,不可混用,以where_X优先)

API Debug

KEYREQUIREDVALUE
app_key *Required
model_name *Required
database Option
op_funs *Required
op_fields *Required
logic Option
where Option

API Response

KEYTypeDescription
err_codeInt状态操作码,0成功;1开发类错误,获取失败(表单不存在);2应用层规则拦截,拦截后可以小白开放平台查看日记;3No-data-found
err_msgString错误提示信息,err_code非0时参考此提示信息
reportObject聚合运算的表格数据
report.SUM_fieldmixed返回的字段是动态的名称,字段名是:聚合运算名+下划线+字段名,例如:SUM_field。失败时返回 NULL,根据运算和字段类型不同,返回结果可能是int,也可能是string类型,或浮点数。

HTTP Response Code

HTTP Status CodeDescription
Http Status = 200Success
Http Status = 400Illegal-Params
Http Status = 401Illegal-Token
Http Status = 402IP-Banned
Http Status = 404API-NOT-Exsits
Http Status = 406Illegal-APPKEY
Http Status = 407APPKEY-Expired-Out
Http Status = 408APPKEY-Busy
Http Status = 409Illegal-Sign
Http Status = 413API-Traffic-NOT-Enough
Http Status = 415API-LOCKED
Http Status = 500Internal-Server-Error