观远 BI

卡片相关API

创建于 2022-11-16 / 最近更新于 2023-07-21 / 4912
字体: [默认] [大] [更大]

1. 卡片相关API概述

Public API,是指观远数据为系统集成提供的标准化开放接口。系统集成,通常是指将各个分离的设备(如个人电脑)、系统、功能和信息等集成到相互关联的、统一和协调的系统之中,使资源达到充分共享,实现集中、高效、便利的管理。系统集成实现的关键在于解决系统之间的互连和互操作性问题,是一个多厂商、多协议和面向各种应用的体系结构。

观远数据提供一套简便的验证机制,来供私有化部署用户进行外部系统和账户对接集成,实现集中、高效、便利的管理。本文将为您详细介绍观远数据为您提供的与卡片相关的 Public API。

2. 卡片相关API列表速览

目前,与卡片相关的 Public API 共包含1个,列表如下:

序号接口描述PATH
1获取卡片数据/public-api/card/{cardId}/data

3. 卡片相关API具体说明

3.1 获取卡片数据

请求方式: POST

请求地址:/public-api/card/{cardId}/data

3.1.2 参数说明

参数名参数值说明Location类型是否必填备注
cardId卡片IDPathString--
X-Auth-Token登录用的TokenHeaderStringToken需要通过sign-in接口获取
dynamicParams动态参数BodyJSON
dpId:动态参数ID;
name:动态参数名称;
valueType:动态参数类型,支持NUMBER,DATE,STRING三种;
defaultValue:动态参数默认值;
fdId:动态参数应用的field的ID;
customize:动态参数是否为自定义参数;
optionValue:动态参数可选项
filter过滤器BodyJSON

指定过滤条件,包括name,filterType,filterValue

name:过滤的列名(注意填原始名字,不要填卡片里的别名);

filterType:过滤类型;

filterValue:过滤值

limit获取的数据条数BodyInt
--
offset数据的起始位置BodyInt
--
view数据获取方式BodyString

GRAPH:图形形式

GRID:表格形式

3.1.3 请求与响应示例

POST Body Sample:

{
    "dynamicParams": [],
    "filters": [{
        "name": "gender",
        "filterType": "IN",
        "filterValue": ["F"]
        }],
    "limit": 200,
    "offset": 0,
    "view": "GRAPH"
}
{    
   "dynamicParams": [],
   "filters": [{
       "name": "gender",
       "filterType": "IN",
       "filterValue": ["F"]
       }],
   "limit": 200,
   "offset": 0,
   "view": "GRID"
}

其中,filterType(过滤器)支持以下形式:

  • GT (>), GE (>=), LT (<), LE(<=), EQ (==), NE (!=),

  • IN (IN LIST), NI (NOT IN LIST),

  • STARTSWITH, NOT_STARTSWITH,

  • ENDSWITH, NOT_ENDSWITH,

  • CONTAINS, NOT_CONTAINS,

  • IS_NULL, NOT_NULL

"dynamicParameters": [
 {
   "dpId": "d86bf14fa17ba4d2a8971da2",
   "name": "TEST",
   "valueType": "NUMBER",
   "defaultValue": "25",
   "fdId": "rd7e3c36a27e34f8aa7d02f2",
   "customize": true,
   "optionValue": [
     "123",
     "234"
   ]
 }
]


Response Sample:

{
    "chartMain": {
        "meta": {
            "categories": [
                {
                    "name": "大类代码",
                    "displayName": "大类代码",
                    "parentFdName": null,
                    "fdId": "d1a63a97399464c7bb704ea9",
                    "fdType": "LONG",
                    "granularity": null
                }
            ],
            "series": [
                {
                    "cols": [
                        {
                            "value": null
                        }
                    ],
                    "metric": {
                        "name": "单价",
                        "fdType": "DOUBLE",
                        "idx": 0
                    }
                }
            ],
            "direction": "vertical",
            "splitSetting": null,
            "dataLabels": {
                "metric": {
                    "showSeries": false,
                    "showCategory": false,
                    "showNumber": true,
                    "fontSize": 12,
                    "separator": "comma",
                    "position": "outside"
                },
                "metricAdditional": {
                    "showSeries": false,
                    "showCategory": false,
                    "showNumber": false,
                    "fontSize": 12,
                    "separator": "comma",
                    "position": "outside"
                }
            },
            "axes": {
                "categoryAxis": {
                    "showTitle": false,
                    "title": null,
                    "autoStep": true,
                    "step": "",
                    "distance": "",
                    "visible": true
                },
                "mainAxis": {
                    "tickInterval": null,
                    "max": "",
                    "unit": null,
                    "tickPosition": null,
                    "autoTickInterval": true,
                    "visible": true,
                    "min": "",
                    "distance": "",
                    "autoExtremes": true,
                    "showGridLine": true,
                    "title": null,
                    "showTitle": false,
                    "minorTickPosition": null
                },
                "navigator": {
                    "showNavigator": false
                }
            },
            "auxiliaryLine": null,
            "theme": null,
            "colors": [
                "#0781C3",
                "#FF7500",
                "#83BFF4",
                "#FFB86C",
            ]
        },
        "colorAxis": {
            "title": {
                "text": "大类代码"
            },
            "format": null
        },
        "limitInfo": {
            "hasMoreData": false,
            "dataLimit": 5000,
            "hasMoreCol": false,
            "colLimit": 5000
        },
        "categories": [
            "1",
            "2"
        ],
        "series": [
            {
                "name": "单价",
                "data": [
                    {
                        "y": 60.269,
                        "colorBy": 1
                    },
                    {
                        "y": 43.03,
                        "colorBy": 2
                    }
                ],
                "format": null
            }
        ]
    },
    "view": "GRAPH",
    "rawDataNotChanged": false,
    "chartType": "BASIC_COLUMN",
    "cardType": "CHART"
}

此结果按照图形的展示要求组织,横轴数据为 categories,纵轴数据为 series。

{
   "chartMain": {
       "row": {
           "meta": [
               {
                   "fdId": "d1a63a97399464c7bb704ea9",
                   "title": "大类代码",
                   "originTitle": "大类代码",
                   "fdType": "LONG",
                   "metaType": "DIM",
                   "parentFdName": null,
                   "granularity": null,
                   "headerFormat": null
               }
           ],
           "values": [
               [
                   {
                       "titleType": "LONG",
                       "granularity": null,
                       "title": "1"
                   }
               ],
               [
                   {
                       "titleType": "LONG",
                       "granularity": null,
                       "title": "2"
                   }
               ]
           ],
           "dimThreshold": [
               null
           ],
           "showAsPicture": [
               null
           ]
       },
       "column": {
           "meta": [
               {
                   "title": "度量",
                   "metaType": "METRIC",
                   "headerFormat": null
               }
           ],
           "values": [
               [
                   {
                       "title": "单价",
                       "type": "metric",
                       "fmt_idx": 0,
                       "fdType": "DOUBLE",
                       "headerFormat": null
                   }
               ]
           ],
           "dimThreshold": [],
           "showAsPicture": [],
           "format": [
               null,
               null
           ],
           "threshold": [
               null,
               null
           ]
       },
       "data": [
           [
               {
                   "v": 60.269
               }
           ],
           [
               {
                   "v": 43.03
               }
           ]
       ],
       "meta": {
           "dataLabels": {
               "metric": {
                   "showSeries": false,
                   "showCategory": false,
                   "showNumber": true,
                   "fontSize": 12,
                   "separator": "comma",
                   "position": "outside"
               },
               "metricAdditional": {
                   "showSeries": false,
                   "showCategory": false,
                   "showNumber": false,
                   "fontSize": 12,
                   "separator": "comma",
                   "position": "outside"
               }
           },
           "axes": {
               "categoryAxis": {
                   "showTitle": false,
                   "title": null,
                   "autoStep": true,
                   "step": "",
                   "distance": "",
                   "visible": true
               },
               "mainAxis": {
                   "tickInterval": null,
                   "max": "",
                   "unit": null,
                   "tickPosition": null,
                   "autoTickInterval": true,
                   "visible": true,
                   "min": "",
                   "distance": "",
                   "autoExtremes": true,
                   "showGridLine": true,
                   "title": null,
                   "showTitle": false,
                   "minorTickPosition": null
               },
               "navigator": {
                   "showNavigator": false
               }
           }
       },
       "offset": 0,
       "limit": 200,
       "hasMoreData": false,
       "count": 2,
       "limitInfo": {
           "hasMoreData": false,
           "dataLimit": 20000,
           "hasMoreCol": false,
           "colLimit": 100
       }
   },
   "view": "GRID",
   "rawDataNotChanged": false,
   "chartType": "BASIC_COLUMN",
   "cardType": "CHART"
}

获取的数据形式按照行(row)、列(column)表头以及数据块(data)的形式组织。

29 人点赞过