Tablis Developer Guide. API

Everything you can do in the Tablis base interface can also be done through the API: view and change the data structure, import data, create and run queries. The API uses the same authorization and access control as the base interface. The interface itself is described in the Tablis User Guide.

Call format

From an application server (with the authorization token obtained via the auth command):

https://tablis.ru/api/{db}/{cmd}[/{id объекта}][?{параметры}]

From the user's browser (the token is already in a cookie; the JSON parameter returns the response as JSON):

https://tablis.ru/{db}/{cmd}[/{id объекта}]?JSON[&{параметры}]

Here {db} is the database name, {id объекта} is the object id, {параметры} are the request parameters, and {cmd} is a command from the table below.

Command types

The cmd parameter can have one of two prefixes for data-changing commands:

  • _d_* — changes to the data structure (DDL, Structure Editor commands);
  • _m_* — changes to the data itself (DML, base interface commands).

All other commands return JSON with the data the system uses to build its forms.

All data-changing requests are sent as POST and require an XSRF token (the _xsrf parameter). The Content-Type: application/x-www-form-urlencoded header is usually required as well.

The response is either the set of parameters for building the next base interface screen, exactly as if the command had been submitted from an interface form, or an error message.

Authorization

The auth command gives the client a token, which it then passes in the X-Authorization: {токен} header ({токен} being the token) with every request prefixed with api/.

A simpler option is Basic HTTP Authentication, where the user name and password are sent in the header of every request:

Authorization: Basic Username:Password

Under RFC 7617 the Username:Password fragment must be Base64-encoded, but for simplicity you may also send it unencoded — that works too.

Command list

cmd Method Object id Description params Request example Response example Data array
auth POST — Authenticates the user; returns the XSRF and authorization tokens login={пользователь}, pwd={пароль} (user name, password) /api/{db}/auth; POST parameters: login={db}, pwd=******* Success: {"_xsrf":"ef1bbd56839b1e97636a5","token":"67a450965bf763cd719b5fcdb4ca41","msg":null}; failure: {"failed":"wrong"}
_d_alias POST id Save an alias for a reference attribute val={значение} (value)
_d_attrs POST id Save attribute settings (default value) val={значение}
_d_del POST id Delete a type
_d_del_req POST id Delete an attribute
_d_multi POST id Enable/disable multiple selection for a reference attribute
_d_new POST — Create a new type (table) val={значение}; unique=1 (1 — the first column is unique, empty — not unique); t={id базового типа} (base type id)
_d_null POST id Set/clear the "Required" flag on an attribute
_d_ref POST id Create a reference to a type
_d_req POST id Add an attribute t={id типа реквизита} (attribute type id) /api/{db}/_d_req/18?t=322; POST parameters: _xsrf=d0aff7cd045d1b1 {"id":1826,"obj":18,"next_act":"edit_types","args":"ext","warnings":""}
_d_save POST id Save the type name, its base type and the uniqueness flag val={значение}; unique=1 (pass if set); t={id базового типа}
_d_up POST id Move an attribute one position up among its siblings
_m_del POST id Delete an object
_m_move POST id Move a child object under a different parent up={id целевого родителя} (target parent id)
_m_new POST type id Create an object of the given type Object: t{id типа}={значение} (type id, value); for a child type: up={id родителя} (parent id); optional attributes: t{id типа}={значение}
_m_save POST id Save the object's value and attributes, if provided Object: t{id типа}={значение}; attributes: t{id типа}={значение}
_m_set POST id Change / create / delete an object attribute Attributes: t{id типа}={значение} /api/{db}/_m_set/165; POST parameters: t115=145, _xsrf=d0aff7cd045d1b1
_m_up POST id Move an object one position up among its siblings /api/{db}/_m_up/165; POST parameters: _xsrf=d0aff7cd045d1b1 {"id":"116","next_act":"object","args":"F_U=145"}
backup POST id Create a database archive (in development)
dict GET — List of independent object types /api/{db}/dict See the dict response example List of types as an object
dir_admin GET, POST — List of files and directories, actions on them
edit_obj GET id Data for the object edit form
edit_types GET — Data for the Structure Editor
object GET, POST type id Data for the list form of a type's instances; delete command _m_del_select — if this parameter is passed, all objects matching the current filter are deleted /api/{db}/object/1141 See the object response example Data for building the table
report GET, POST report id Data of an executed query (report), its parameters, command to apply changes _m_confirmed — if this parameter is set, the query's changes are applied

Response examples

dict command response

Request:

GET https://tablis.ru/api/{db}/dict

Response:

{
  "18": "User",
  "22": "Query",
  "29": "Format",
  "42": "Role",
  "47": "Grant",
  "63": "Function",
  "65": "Total",
  "137": "Form"
}

object command response

Request:

GET https://tablis.ru/api/{db}/object/1141

Response:

{
  "type": {
    "id": 1141,
    "up": 1,
    "val": "Product",
    "base": "SHORT"
  },
  "base": {
    "id": "3"
  },
  "req_base": {
    "1274": "SIGNED"
  },
  "req_base_id": {
    "1274": "14"
  },
  "req_attrs": {
    "1274": ""
  },
  "req_type": {
    "1274": "Quantity"
  },
  "req_order": [
    "1274"
  ],
  "object": [
    {
      "id": "1146",
      "up": "1",
      "val": "Bolt",
      "base": "1141"
    },
    {
      "id": "1148",
      "up": "1",
      "val": "Nut",
      "base": "1141"
    },
    {
      "id": "1147",
      "up": "1",
      "val": "Washer",
      "base": "1141"
    }
  ],
  "reqs": {
    "1146": {
      "1274": "0.00"
    },
    "1147": {
      "1274": "120.00"
    },
    "1148": {
      "1274": "340.00"
    }
  }
}

Support

Questions about the API and the on-premise edition of Tablis — Digital Structures LLC: tablispro@yandex.ru, +7 (931) 255-57-77.

Ready to move your processes to Tablis?

We will show the platform on your own tasks or prepare a quote for the on-premise edition.