# API

## **Specs**

| Label                     | Value                        |
| ------------------------- | ---------------------------- |
| **Version**               | 2.2.0 (updated on 2025-5-05) |
| **Developer**             | Labii Inc.                   |
| **Type**                  | Column                       |
| **Support Configuration** | Yes                          |
| **Support Readonly view** | Yes                          |
| **Support Edit view**     | Yes                          |
| **Support Form view**     | Yes                          |
| **Support Default value** | Yes                          |
| **Support Import**        | Yes                          |
| **Allow multiple**        | Yes                          |

## Overview

The Labii API widget is a powerful tool that allows users to seamlessly connect to various APIs and execute API calls with ease. Its flexibility enables users to customize essential elements such as headers, request bodies, and pre-request scripts for preparing POST data. Additionally, the widget supports post-response scripts, allowing users to efficiently update and manage data based on the responses received. With Labii, integrating and interacting with APIs becomes streamlined and highly customizable, catering to diverse application needs.

## Use case

* Integrate with Quickbooks API to create invoices.
* Pull down chemical structures based on chemical name.

## Configuration

To enable the widget's functionality, it requires the following configuration.

* **Authorization Information**
  * **Bearer Token** - Bearer Token or any other authorization string. Bearer Tokens are the predominant type of access token used with OAuth 2.0. For example: Bearer eyJraWQiOiIy
  * **OAuth 2.0 Provider** - If your API requires OAuth 2.0 for authorization, please select one of the available providers. If you’re interested in a provider that isn’t listed, feel free to contact us by create a support ticket.
  * **Refresh Token** - The refresh token is used to obtain a new access token when the current access token becomes invalid or expires. It will be used only when the OAuth 2.0 provider is selected.
* **API Call Methods -** The methods to call the API. Each method displays a button to call the API. The button text and icon can be customized.
  * **Name -** Name of the method. It is the text to display for the button. The name have to be unique.
  * **Icon** - The icon for the method.
  * **Method**
    * Get
    * Post
    * Put
    * Patch
    * Delete
  * **URL** - The request URL.
  * **Headers** - The headers to send with the request in JSON format. The Authorization header is automatically added if provided. The 'Content-Type' will be automatically updated if uploading a Labii file.
  * **Query Params** - The parameters to send with the request as query. e.g. id=1\&name=labii
  * **Body** - The body to send with the request in the JSON format. Use '{file: {sid: 'xxx', name: 'xxx'}}' to upload a Labii file.
  * **Pre Request Scripts** - The script to run before the request is sent. Return data as the variables object so that it will be used in the body. Labii SDK is supported, learn more at <https://docs.labii.com/api/sdk/sdk-javascript>
  * **Mapper** - The mapper to map the data from the API response to the Labii data in the JSON format. The value is passed as 'data'. Field: Use the filed as the key. e.g. {'name': 'name'}. Column: Use the column id as the key. e.g. {'xxx': 'customer.name'}. Use nested key to access the nested object. e.g. {'name': 'name.first\_name'}.
  * **Post Response Scripts** - The script to run after the response is received. The response data will be passed as 'data' object. Pass additional keys to the data object to be used in the mapper. Labii SDK is supported, learn more at <https://docs.labii.com/api/sdk/sdk-javascript>
  * **Should use request proxy** - If checked, the request will be sent through the Labii server. This is useful when the domain is blocked via CROS.
  * **Should auto update when empty** - If checked, this method will be executed when no data in current column.

### Example

```json
{

}
```

## Views

See the interface of the widget in the following views.

### **Readonly view**

A read-only interface displays buttons for each defined API method. Clicking a button triggers the associated API requests.

<figure><img src="/files/uOZAoYOAFOcNeGrNs04V" alt=""><figcaption></figcaption></figure>

### **Edit view**

The Edit view closely resembles the [Text](/widgets/column-widgets/form/text-inputs/text.md) widget, allowing you to input specific text or an ID. Typically, this text or ID is recognized as the API object ID.

<figure><img src="/files/yKZyfI1stP33Az7RWeAD" alt=""><figcaption></figcaption></figure>

### **Form view**

The form view is identical to the Edit view.

## Data

Each widget in Labii stores data in a unique manner; refer below to understand how data from this widget is stored.

### Data format

Any text data.

### **Default value**

The Default Value field within the column allows you to specify the default value when a record is created.

Default value can be any text data.

### **Import value**

The Import Value is the value you need to include in your Excel table for it to be imported into Labii.

Import value can be any text data.

## Tutorials:

* Create Stripe Payment Link with API widget. (<https://youtu.be/wNvV2tQlzm8>)
* Post to Social Media Automatically with API widget. (<https://youtu.be/MbOqKlNLHfE>)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.labii.com/widgets/column-widgets/integration/api/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
