Skip to main content

Step5. Access Backend with API

Hexabase's backend is accessible via Web API.

Here, let's call the ToDo sample via API.

Demo Video

What to prepare

It is recommended to use some kind of API development tool/API test tool to verify the operation of the API.

For information on how to use each tool, please refer to the official website.

Information to confirm in advance

To use the API, you will need the API's base URI and account information.

API base URI

EnvironmentAPI base URIAdmin panel URI
Productionhttps://api.hexabase.comhttps://app.hexabase.com
Verificationhttps://stg-api.hexabase.comhttps://stg.hexabase.com

Account information

  • Hexabase account information (ID, password)
  • API execution results are subject to the authority of the account executing the API.

Basic API operations

The flow of operating Hexabase with API is as follows.

  1. Log in and get a token
  2. Specify a token and select a workspace
  3. Get application information by specifying token and workspace ID
  4. Call the required API by specifying the token and target ID

Screen item ID (display_id) and internal ID

There are two types of Hexabase IDs. The 「screen ID/screen item ID」, which can be set to any value that is easy to understand, and the (internal ID), which is identified within the system.

The screen item ID can be set on the admin panel.

1. Login with API

To log in with the API, call the following API: At this time, specify the account ID (email) and password in the request body.

Post    https://api.hexabase.com/api/v0/login

Request Body

{
"email": "[email protected]",
"password": "**********"
}

As a result, a token will be returned in the response body.

{
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

2. Select workspace with API

To select a workspace with the API, call the following API: At this time, specify the token obtained at login in the request header.

Get    https://api.hexabase.com/api/v0/workspaces

Request Header

Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

As a result, workspace information is returned in the response body.

{
"workspaces": [
{
"workspace_id": "60594049dabf490001d84684",
"workspace_name": "demo_workspace"
},
{
"workspace_id": "60d45d336d66ed844b1190fe",
"workspace_name": "demo_developer"
}
],
"current_workspace_id": "60d45d336d66ed844b1190fe"
}

3. Get application information with API

To get application information with API, call the following API: At this time, specify the workspace ID (workspace_id) as the API Params and the token obtained at login in the request header.

Get    https://api.hexabase.com/api/v0/workspaces/:workspace-id/applications

Params

workspace_id: 60d45d336d66ed844b1190fe

Request Header

Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

As a result, application information is returned in the Response Body.

[
{
"application_id": "60d45d336d66ed844b119101",
"name": "新しいアプリケーション",
"display_id": "new_app",
"datastores": [
{
"datastore_id": "60d45d51dbf1fd0948253d8d",
"name": "新しいデータベース",
"display_id": "new_db"
}
]
},
{
"application_id": "60d5b2bbfc2b8d27e799d8b6",
"name": "hexa-simple-example",
"display_id": "APP-todo1",
"datastores": [
{
"datastore_id": "60d5b2bb77d6297bc49699de",
"name": "TODOサンプル",
"display_id": "Db-todo1"
}
]
}
]

4. Get database item list with API

To get the database item list with the API, call the following API. Then specify the following values:

API Param

  • app-id = ApplicationID(display_id)
  • datastore-id = DatabaseID(display_id)

Request header

  • Token obtained at login

Request body

  • Search conditions and output format

To work with an application, specify the application's display_id as the app-id. To work with a database, specify the display_id of the database as the datastore-id.

The display_id can be checked and set on the admin panel.

Post    https://api.hexabase.com/api/v0/applications/:app-id/datastores/:datastore-id/items/search

Params

app-id: APP-todo1
datastore-id: Db-todo1

Request Header

Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Request Body

{
"use_or_condition": false,
"page": 1,
"per_page": 0,
"use_display_id": true,
"return_number_value": true
}

As a result, a list of items will be returned in the Response Body.

{
"items": [
{
"Assignee": "X",
"Category": "A",
"DueDate": "2020-04-04T15:00:00Z",
"Status": "完了",
"Title": "タスクE",
"created_at": "2020-08-25T08:59:20Z",
"created_by": "IMPORT",
"d_id": "60d5b2bb77d6297bc49699de",
"i_id": "60d5b2bddbf1fd0948253e1a",
"p_id": "60d5b2bbfc2b8d27e799d8b6",
"rev_no": 2,
"seed_i_id": "5f525616412f7a0001e93d5c",
"status_id": "60d5b2bb77d6297bc49699e6",
"title": "タスクE",
"unread": 0,
"updated_at": "2020-08-25T09:05:33Z",
"updated_by": "5f253590c6e47b366d3d92d4",
"w_id": "60d45d336d66ed844b1190fe"
},
{
"Assignee": "X",
"Category": "B",
"DueDate": "2020-04-03T15:00:00Z",
"Status": "確認",
"Title": "タスクD",
"created_at": "2020-08-25T08:59:20Z",
"created_by": "IMPORT",
"d_id": "60d5b2bb77d6297bc49699de",
"i_id": "60d5b2bddbf1fd0948253e1b",
"p_id": "60d5b2bbfc2b8d27e799d8b6",
"rev_no": 2,
"seed_i_id": "5f525616412f7a0001e93d5d",
"status_id": "60d5b2bb77d6297bc49699e9",
"title": "タスクD",
"unread": 0,
"updated_at": "2020-08-25T09:05:06Z",
"updated_by": "5f253590c6e47b366d3d92d4",
"w_id": "60d45d336d66ed844b1190fe"
},
{
"Assignee": "Y",
"Category": "C",
"DueDate": "2020-04-02T15:00:00Z",
"Status": "作業中",
"Title": "タスクC",
"created_at": "2020-08-25T08:59:20Z",
"created_by": "IMPORT",
"d_id": "60d5b2bb77d6297bc49699de",
"i_id": "60d5b2bddbf1fd0948253e1c",
"p_id": "60d5b2bbfc2b8d27e799d8b6",
"rev_no": 2,
"seed_i_id": "5f525616412f7a0001e93d5e",
"status_id": "60d5b2bb77d6297bc49699ea",
"title": "タスクC",
"unread": 0,
"updated_at": "2020-08-25T09:04:29Z",
"updated_by": "5f253590c6e47b366d3d92d4",
"w_id": "60d45d336d66ed844b1190fe"
},
{
"Assignee": "Y",
"Category": "A",
"DueDate": "2020-04-01T15:00:00Z",
"Status": "受付",
"Title": "タスクB",
"created_at": "2020-08-25T08:59:20Z",
"created_by": "IMPORT",
"d_id": "60d5b2bb77d6297bc49699de",
"i_id": "60d5b2bddbf1fd0948253e1d",
"p_id": "60d5b2bbfc2b8d27e799d8b6",
"rev_no": 2,
"seed_i_id": "5f525616412f7a0001e93d5f",
"status_id": "60d5b2bb77d6297bc49699e8",
"title": "タスクB",
"unread": 0,
"updated_at": "2020-08-25T09:04:06Z",
"updated_by": "5f253590c6e47b366d3d92d4",
"w_id": "60d45d336d66ed844b1190fe"
},
{
"Assignee": "Y",
"Category": "B",
"DueDate": "2020-03-31T15:00:00Z",
"Status": "新規",
"Title": "タスクA",
"created_at": "2020-08-25T08:59:20Z",
"created_by": "IMPORT",
"d_id": "60d5b2bb77d6297bc49699de",
"i_id": "60d5b2bddbf1fd0948253e1e",
"p_id": "60d5b2bbfc2b8d27e799d8b6",
"rev_no": 2,
"seed_i_id": "5f525616412f7a0001e93d60",
"status_id": "60d5b2bb77d6297bc49699e7",
"title": "タスクA",
"unread": 0,
"updated_at": "2020-08-25T09:03:38Z",
"updated_by": "5f253590c6e47b366d3d92d4",
"w_id": "60d45d336d66ed844b1190fe"
}
],
"totalItems": 5
}

Hexabase's frontend application combines these APIs to exchange data with the backend.

Next, let's start the frontend sample locally.