Retrieve data source column metadata using a REST API
Introduction
Bold BI’s REST API provides a seamless way to programmatically interact with the platform, including the ability to retrieve data source column metadata
REST API for Obtaining an Access Token
Before making any changes, it is necessary to authenticate with the Bold BI server to obtain an access token. This token must be included in the header of all API requests to ensure they are authorized.
Authentication Endpoint
Field | Value |
---|---|
URL | http://{domain}/bi/api/site/{sitename}/token |
Method | POST |
Content-Type | application/json |
Request Body Schema
{
"username": "string",
"password": "string",
"grant_type": "password"
}
username
: The email address of the user.password
: The password of the user.grant_type
: The type of credentials used to authorize the request for an access token. The value allowed ispassword
.
Response
{
"access_token": "string",
"token_type": "string",
"expires_in": "string",
"Email": "string"
}
Example
Request | Response |
---|---|
Get the data source Id
Option 1: Get the Data source from UI
- Select the three dots located on the data source within the data source page, and then click on the Info option.
- Please refer to the screenshot below and note down the item ID.
Option 2: Get the Data sources from REST API
Users who have created the data sources can view the lists of data sources, Get DataSources
Retrieving metadata on columns from a specified data source using the API.
Once authenticated, you can proceed to retrieving metadata on columns from a specified data source by sending a GET
request to the appropriate endpoint.
API Endpoint
- URL:
http://{domain}/bi/api/site/{sitename}/v5.0/datasource/getcolumns/{itemId}
- Method:
GET
- Content-Type:
application/json
- Authorization:
Bearer <access_token>
Response
{
"ApiStatus": true,
"Data": [
{
"Name": "string",
"DesiredType": "string",
"DataType": "string",
"DefaultDataType": "string",
"IsVisible": bool
}
],
"Status": true
}
Field | Description |
---|---|
Name |
Column name |
DesiredType |
The original name of the column. |
DataType |
The type of data currently being used. |
DefaultDataType |
The default data type. |
IsVisible |
Display the column either in a hidden or visible state. |
Below is an example API request that returns the available columns and its data type details, as shown in the UI above.
Conclusion
By following these steps, you can successfully get the data source columns metadata using Bold BI’s REST API.
Additional References