Lookup Tables API
Lookup Tables API
The API reads a SmartLookup or a SimpleLookup table as a tree of column headers and rows that mirror it, replaces them,
and appends rows. The tableType of the table is SmartLookup or SimpleLookup; both use the same model.
All table types share the same endpoints and the same rules for the project and the table id; see Table Endpoints.
Reading a Table
GET /rest/projects/{projectId}/tables/{tableId}
Response (200 OK):
{
"id": "7Q2K9MX4RB8TZ1HD",
"tableType": "SmartLookup",
"kind": "Rules",
"name": "CoverageRate",
"returnType": "Double",
"args": [
{"name": "coverageForm", "type": "CoverageForm"},
{"name": "numberOfEmployees", "type": "Integer"},
{"name": "area", "type": "String"}
],
"headers": [
{"title": "Coverage Type"},
{"title": "Limit"},
{"title": "<= 14", "children": [{"title": "Low"}, {"title": "High"}]},
{"title": ">= 15", "children": [{"title": "Low"}, {"title": "High"}]}
],
"rows": [
{
"Coverage Type": "Basic",
"Limit": 100,
"<= 14": {"Low": 20, "High": 30},
">= 15": {"Low": 30, "High": 66}
},
{
"Coverage Type": "Basic",
"Limit": "[200.0..300.0]",
"<= 14": {"Low": 30, "High": 50},
">= 15": {"Low": 60, "High": 88}
}
]
}
The response leaves out the empty values: a header without children has no children, and a row has no key for an
empty cell.
Headers and Rows
- Header — a column title. A header with
childrengroups the columns of its children; a header without them is one column. - Row — an object keyed by the title of each top-level header. The value of a header without children is the cell. The value of a header with children is an object keyed by the titles of the children.
- Titles are keys — the same title under two parents, such as
Lowunder<= 14and under>= 15, is a different key in each nested object. - Cells — a number, a boolean, or a string. A range or a condition is a string, such as
[200.0..300.0].
Schematically, the first row of the table above is this part of the workbook:
SmartLookup Double CoverageRate (CoverageForm coverageForm, Integer numberOfEmployees, String area)
Coverage Type | Limit | <= 14 | >= 15
| | Low | High | Low | High
Basic | 100 | 20 | 30 | 30 | 66
Writing a Table
Replace the Headers and the Rows
PUT /rest/projects/{projectId}/tables/{tableId}
Content-Type: application/json
The body has the same fields as the response. A row needs an object for every header that has children.
Append Rows
POST /rest/projects/{projectId}/tables/{tableId}/lines
Content-Type: application/json
{
"tableType": "SmartLookup",
"rows": [
{
"Coverage Type": "Additional",
"<= 14": {"Low": 30, "High": 50},
">= 15": {"Low": 60, "High": 88}
}
]
}
The titles of the rows are matched with the headers of the table in the workbook, not with headers of the request. A key that is not in a row leaves the cell empty.
A write answers 204 No Content, or 200 OK with the current table id when it renamed the table or the request
named the table by an id it had before; see Data Tables API.
Models
LookupView
id,tableType,kind,name,properties— as for a Data table.tableTypeisSmartLookuporSimpleLookup, andkindisRules.returnType— the type of the value the table returns.args— the list of arguments. Each has anameand atype.collect— whether the table uses theCollectkeyword to aggregate the matching rows.headers— the list ofLookupHeaderView.rows— the list of rows, each an object as described above.messages,runState,partial— read-only; see Table Endpoints.
LookupHeaderView
title— the title of the column.children— the list ofLookupHeaderViewthat the header groups.
LookupAppend
tableType—SmartLookuporSimpleLookup.rows— the list of rows to append.