Skip to main content

Concepts

The Labii API is a REST API that provides programmatic access to the Labii platform. It supports all different calling methods, including GET, POST, PUT, and DELETE.

The Labii API is designed to be accessible and flexible, allowing developers to use the programming language and tools of their choice to interact with the Labii platform. The API is fully documented and provides detailed information about each of its endpoints, including the HTTP method, endpoint URL, required parameters, and expected response.

Some of the key features of the Labii API include:

  1. Resource-based architecture: The Labii API uses a resource-based architecture, which means that each endpoint represents a specific resource in the Labii platform, such as a project, experiment, or row.
  2. Authentication and authorization: The Labii API uses OAuth 2.0 for authentication and authorization, ensuring that only authorized users can access sensitive data.
  3. Pagination and filtering: The API provides support for pagination and filtering, allowing developers to retrieve specific subsets of data based on various criteria.

URL​

The Labii API uses two types of URLs to represent two different views of an object:

  1. List of objects: {{base_url}}/{app}/{model}/list/{level}/{sid}/{serializer}/
  2. Detail of an object: {{base_url}}/{app}/{model}/detail/{sid}/

The base_url is set to https://www.labii.dev/ by default. If your organization has a dedicated server, you can use https://[your subdomain].labii.dev/ as the base_url.

The app parameter represents the name of the application, while the model parameter represents the name of the model. You can refer to the Labii documentation for more details on these parameters.

The level parameter represents the scope of records to retrieve. You can refer to the Levels section of the Labii documentation for more details on this parameter.

The sid parameter is a static and encrypted Labii object ID. It must match with the level parameter. For example, if level=organization, the sid parameter must be the SID of the organization.

Finally, the serializer parameter represents the scope of fields of the return data. There are three options available:

  • name: Returns only the SID and name of the object, which is very fast.
  • list: Returns selected fields of the objects, which is fast.
  • detail: Returns all fields of the objects, which is slow.

Objects​

The Labii API provides various objects that represent different types of entities in the Labii platform, each with a set of methods for interacting with that entity. Below is a list of objects available in the Labii API along with their descriptions, the app they belong to, and their corresponding model:

NameDescriptionAppModel
OrganizationRepresents the organization objectorganizationsorganization
PersonnelRepresents a member of the organizationorganizationspersonnel
TeamRepresents a team of the organizationorganizationsteam
Organization WidgetRepresents the installed widgets in the organizationorganizationsorganizationwidget
StatementRepresents the monthly statementorganizationsstatement
BackupRepresents the backup dataorganizationsbackup
ProjectRepresents the project objectprojectsproject
Project MemberRepresents a project member or teamprojectsmember
TableRepresents the table objecttablestable
ColumnRepresents the columns of a tabletablescolumn
RowRepresents the rows of a tabletablesrow
CellRepresents the cells of a rowtablescell
SectionRepresents the sections of a rowtablessection
VersionRepresents the versions of a rowtablesversion
FilterRepresents the filters of a tabletablesfilter
WorkflowRepresents the workflow of a tabletablesworkflow
StepRepresents the steps of a workflowtablesstep
ActivityRepresents user activitiesactivitiesactivity
WidgetRepresents the widget objectwidgetswidget

Levels​


Levels define the scope of records to retrieve. The level parameter is a required parameter for the list API. Labii uses the following levels:

  • organization: returns the results within the organization level.
  • user: returns the results for a particular user (deprecated).
  • project: returns the results for a project (deprecated).

Not all levels are available for all list APIs. If a wrong level is used, an HTTP_406_NOT_ACCEPTABLE error will be returned. The table below lists all the allowed levels for each API.

List APIlevel=organizationlevel=userlevel=project
Organization ListYesYes-
Organization Member ListYes--
Team ListYesYes-
Organization WidgetYes--
Statement ListYes--
Backup ListYes--
Project ListYesYes-
Project Member ListYes-Yes
Table ListYes--
Column ListYes--
Filter ListYesYes-
Row ListYesYesYes
Cell ListYes--
Section ListYes--
Version ListYes--
ActivityYesYes-
Widget*--

Methods​

The following documentation describes the methods used in the Labii API:

  • GET: This method is used to fetch one or more objects.
  • POST: This method is used to create an object.
  • PUT: This method is used to update an object.
  • PATCH: This method is used to partially update an object.
  • DELETE: This method is used to remove an object.

Different roles have different permissions in using the methods. There are five roles at the organization level:

  • Admin: The administrators
  • Member: The members of the organization
  • Alumni: The members who have left the organization
  • User: Other Labii users who do not belong to the organization
  • Anonymous: Unauthorized user

And 3 roles at the project level:

  • Project Admin: The administrator of a project
  • Project Edit: The members have edit permission at the project
  • Project View: The members have view permission at the project
APIGETPOSTPUTPATCHDELETE
Organization ListAdmin, MemberAdmin---
Organization DetailAdmin, Member--Admin-
Organization Member ListAdmin, MemberAdmin---
Organization Member DetailAdmin, Member--Admin-
Team ListAdmin, MemberAdmin---
Team DetailAdmin, Member--AdminAdmin
Organization Widget ListAdmin, MemberAdmin--Admin
Organization Widget DetailAdmin, Member---Admin
Statement ListAdmin----
Statement DetailAdmin----
Backup ListAdminAdmin---
Backup DetailAdmin----
Project ListAdmin, Project Admin, Project Edit, Project ViewAdmin---
Project DetailAdmin, Project Admin, Project Edit, Project View--Admin, Project Admin-
Project Member ListAdmin, Project Admin, Project Edit, Project ViewAdmin, Project Admin---
Project Member DetailAdmin, Project Admin, Project Edit, Project View--Admin, Project AdminAdmin, Project Admin
Table ListAdmin, MemberAdmin---
Table DetailAdmin, Member--Admin-
Column ListAdmin, MemberAdmin---
Column DetailAdmin, Member--Admin-
Filter ListAdmin, MemberAdmin, Member---
Filter DetailAdmin, Member--Admin, MemberAdmin, Member
Row ListAdmin, Project Admin, Project Edit, Project ViewProject Admin, Project Edit-Project Admin, Project Edit-
Row DetailAdmin, Project Admin, Project Edit, Project View--Project Admin, Project Edit-
Cell ListAdmin, Project Admin, Project Edit, Project ViewProject Admin, Project Edit---
Cell Detail---Project Admin, Project Edit-
Section ListAdmin, Project Admin, Project Edit, Project ViewProject Admin, Project Edit---
Section DetailAdmin, Project Admin, Project Edit, Project View--Project Admin, Project Edit-
Version ListAdmin, Project Admin, Project Edit, Project View----
Version DetailAdmin, Project Admin, Project Edit, Project View----
Activity ListAdmin, Member----
Activity Detail-----
Widget ListAdmin, Member----
Widget DetailAdmin, Member----

Serializer​

The Serializer in Labii API is used to convert the data from the database into a different format. Each Serializer in Labii represents a different field set to be returned. Labii API supports the following serializers:

  • name: This serializer returns the field of sid and name of a record.
  • list: This serializer returns some basic fields. The set of fields varies for different tables.
  • detail: This serializer returns a full set of fields.

Status Codes​

Here is a list of status code used by Labii API:

  • HTTP_200_OK: return when API call successful
  • HTTP_201_CREATED: return when an object is created
  • HTTP_204_NO_CONTENT: return when an object is successfully deleted
  • HTTP_401_UNAUTHORIZED: return when the user is not authenticated
  • HTTP_403_FORBIDDEN: return when a user does not have permission
  • HTTP_406_NOT_ACCEPTABLE: return when parameter is not correct
  • HTTP_500_INTERNAL_SERVER_ERROR: return on internal errors

Errors​

These are common errors for the list view and detail view.

List view​

  • HTTP_401_UNAUTHORIZED - token is not valid
  • HTTP_403_FORBIDDEN - the user does not have permission to perform the action
  • HTTP_406_NOT_ACCEPTABLE - some parameter provided is not acceptable
    • Wrong level - the level provided is not valid or is not allowed
    • Wrong sid - the sid provided can be not decrypted, or does not match any records
    • Wrong field - Error: the field (xxx) is not allowed!
    • Wrong datatype - list, acceptable data is DICT. Please POST multiple times if you have more than one dataset.

Detail view​

  • HTTP_401_UNAUTHORIZED - token is not valid
  • HTTP_403_FORBIDDEN - the user does not have permission to perform the action
  • HTTP_406_NOT_ACCEPTABLE - some parameter provided is not acceptable
    • Wrong sid - the sid provided can be not decrypted, or does not match any records
    • Wrong field - Error: the field (xxx) can not be updated!

Example​

Get a list of records with curl:

curl -X get https://www.labii.dev/tables/rows/list/organization/xxx/list/ -H "Authorization: Token xxxx"

In Python:

import requests
headers = {
"X-Forwarded-For": "batch",
"Content-Type": "application/json",
"Authorization": "Token %s" % token
}
requests.get(url="https://www.labii.dev/tables/rows/list/organization/xxx/list", headers=headers)