Skip to content

Bulk Create Data Streams

Reference:

Field Description
Name Unique name identifier. It must contain only lowercase alphanumeric characters. The characters ., _ and - are allowed to separate words instead of a space BUT can not be at the beginning or end of the name.
Title The display name to show on the Kelvin UI. It can contain any characters, including spaces.
Description Optional description for the data stream, up to 200 characters.
Type Determines if the data is directly derived from sensors or is processed/calculated. Allowed values: Measurement or Computed.
Semantic Type Provides context or deeper meaning behind the data, beyond just its format or structure. Check Kelvin API for the full list of available semantic types.
Data Type Specifies the kind of data in the stream. Allowed values: Boolean, Number, Object, String.
Unit Defines the measurement unit for data. Check Kelvin API for the full list of available units.

Bulk Create Data Streams

In this example we will create a Data Stream with the Semantic Type Pressure and with the name tubing_pressure.

You can create Data Streams in bulk using the import Data Stream option in Data Streams. To start you need to create your Data Stream list in Excel, Google Sheets or any program that can save to a CSV file format.

On the Data Streams page, click on the Import Data Streams button.

In Step 1, upload your CSV file that you created with all the new Data Stream names you want to create and then click Next.

In Step 2, the file is validated with a check list.

If there is any errors, you will need to correct them and then re-upload the file for re-validation.

There is a special feature in this step that if the units given do not exist on the Kelvin Platform, then they will be automatically created.

Before you can proceed to import you will need to add symbols to each new unit detected. To do this simply click on the Show Details button.

In the Units section you will see red boxed where you need to fill in the relevant details.

Once filled, then you can click on the tick button and then you will see the Import button is active. You can now click on Import and the Data Streams and Units will be created.

The Kelvin API does not need the csv file for creating many Data Streams with one command.

You add all new new Data Streams into an array of objects and then use the /datastreams/bulk/create endpoint.

Unlike the Kelvin UI buik Data Stream import, units will NOT be automatically created. You need to ensure they exist before running this endpoint.

curl -X "POST" \
"https://<url.kelvin.ai>/api/v4/datastreams/bulk/create" \
-H "Authorization: Bearer <Your Current Token>" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"datastreams": [
    {
      "data_type_name": "number",
      "description": "Demo for Documentation",
      "name": "doc_demo_data_stream_01",
      "semantic_type_name": "velocity",
      "title": "Docs Demo Data Stream 01",
      "type": "measurement",
      "unit_name": "pound_per_square_inch"
    },
    {
      "data_type_name": "number",
      "description": "Demo for Documentation",
      "name": "doc_demo_data_stream_02",
      "semantic_type_name": "velocity",
      "title": "Docs Demo Data Stream 02",
      "type": "measurement",
      "unit_name": "percent"
    }
  ]
}'
from kelvin.api.client import Client

# Login
client = Client(config={"url": "https://<url.kelvin.ai>", "username": "<your_username>"})
client.login(password="<your_password>")

# New Data Streams Configurations
datastream_data = {
    "datastreams": [
        {
          "data_type_name": "number",
          "description": "Demo for Documentation",
          "name": "doc_demo_data_stream_01",
          "semantic_type_name": "velocity",
          "title": "Docs Demo Data Stream 01",
          "type": "measurement",
          "unit_name": "pound_per_square_inch"
        },
        {
          "data_type_name": "number",
          "description": "Demo for Documentation",
          "name": "doc_demo_data_stream_02",
          "semantic_type_name": "velocity",
          "title": "Docs Demo Data Stream 02",
          "type": "measurement",
          "unit_name": "percent"
        }
    ]
}

# Create all Data Streams
response = client.datastreams.create_bulk_data_stream(
    data=datastream_data
)

print(response)