GTSDB Logo GTSDB Documentation

GTSDB API Documentation

All payloads are in JSON format. Endpoints are either POST / OR TCP.

Write Operations

Write Single Value

Write a new data point for a specific sensor.

Request Body

{
  "operation": "write",
  "Write": {
    "key": "a_sensor1",
    "Value": 3224242424333.3335
  }
}

Response Body

{
  "success": true
}

Patch Operations

Patch Data Points

Update or insert multiple data points for a specific sensor using CSV format.

Request Body

{
  "operation": "data-patch",
  "key": "sensor1",
  "data": "1717965210,123.45\n1717965211,123.46\n1717965212,123.47"
}

Response Body

{
  "success": true
}

Read Operations

Read Data with Time Range and Downsampling

Read data for a specific sensor within a time range with downsampling.

Request Body

{
  "operation": "read",
  "key": "a_sensor1",
  "Read": {
    "start_timestamp": 1717965210,
    "end_timestamp": 1717965211,
    "downsampling": 3
  }
}

Response Body

{
  "success": true
}

Read Last X Records

Read the last X records for a specific sensor.

Request Body

{
  "operation": "read",
  "key": "a_sensor1",
  "Read": {
    "lastx": 1
  }
}

Response Body

{
  "success": true
}

Multi-Read Data with Time Range

Read data from multiple sensors within a time range with downsampling.

Request Body

{
  "operation": "multi-read",
  "keys": [
    "sensor1",
    "sensor2",
    "sensor3"
  ],
  "read": {
    "start_timestamp": 1717965210,
    "end_timestamp": 1717965211,
    "downsampling": 3
  }
}

Multi-Read Last X Records

Read the last X records from multiple sensors.

Request Body

{
  "operation": "multi-read",
  "keys": [
    "sensor1",
    "sensor2",
    "sensor3"
  ],
  "read": {
    "lastx": 1
  }
}

Subscribe Operations

Subscribe to a Key

Subscribe to updates for a specific sensor.

Request Body

{
  "operation": "subscribe",
  "key": "sensor1"
}

Response Body

{
  "success": true
}

Unsubscribe from a Key

Unsubscribe from updates for a specific sensor.

Request Body

{
  "operation": "unsubscribe",
  "key": "sensor1"
}

Response Body

{
  "success": true
}

Key Operations

Get All Keys

Retrieve a list of all sensor keys in the database.

Request Body

{
  "operation": "ids"
}

Response Body

{
  "success": true
}

Initialize a New Key

Initialize a new sensor key in the database.

Request Body

{
  "operation": "initkey",
  "key": "new_sensor"
}

Response Body

{
  "success": true
}

Rename a Key

Rename an existing sensor key in the database.

Request Body

{
  "operation": "renamekey",
  "key": "old_sensor_name",
  "toKey": "new_sensor_name"
}

Response Body

{
  "success": true
}

Delete a Key

Delete a sensor key from the database.

Request Body

{
  "operation": "deletekey",
  "key": "sensor_to_delete"
}

Response Body

{
  "success": true
}

Other Operations

Flush All Data Points

Make sure all data points are written to disk.

Request Body

{
  "operation": "flush"
}

Response Body

{
  "success": true
}

Ping

It is not an operation, but a message sent from the server to the client to check if the connection is still alive. You can ignore this message. (hint: determine by empty data or "ping" message)

Request Body

Response Body

{
  "success": true
}