Skip to content

CLI Examples

You can interact with the REST JSON API directly from the command line using tools like curl and jq. This is useful for testing, debugging, or building shell scripts.

Prerequisites

Install the required command-line tools:

curl: Included by default in Windows 10 (version 1803) and later. For older versions, download from curl.se

jq: Download from jqlang.github.io/jq/download and add to your PATH, or install via package manager:

winget install jqlang.jq

sudo apt update
sudo apt install curl jq
brew install curl jq

Basic Examples

Using jq filters

The -s flag in curl suppresses the progress meter for cleaner output. The jq tool uses dot notation to navigate JSON structures. Use single quotes in Ubuntu and double quotes in Windows for jq filters.

List all connected device serial numbers

curl -s http://localhost:11395/3.6.0/devices/usb | jq ".devices | keys"
curl -s http://localhost:11395/3.6.0/devices/usb | jq '.devices | keys'
curl -s http://localhost:11395/3.6.0/devices/usb | jq '.devices | keys'

Example output:

[
  "E22377"
]

Extract temperature from a RTD300 device

Get the temperature from RTD300 device with serial number E22377:

curl -s http://localhost:11395/3.6.0/devices/usb | jq ".devices[\"E22377\"].channels.temperature.value.magnitude"
curl -s http://localhost:11395/3.6.0/devices/usb | jq '.devices["E22377"].channels.temperature.value.magnitude'
curl -s http://localhost:11395/3.6.0/devices/usb | jq '.devices["E22377"].channels.temperature.value.magnitude'

Example output:

121.5538101196289

Get all connected devices

curl -s http://localhost:11395/3.6.0/devices/usb | jq
curl -s http://localhost:11395/3.6.0/devices/usb | jq
curl -s http://localhost:11395/3.6.0/devices/usb | jq

Example output:

{
  "devices": {
    "E22377": {
      "channel_list": [
        "temperature"
      ],
      "channels": {
        "temperature": {
          "period_ms": 100,
          "value": {
            "magnitude": 121.5538101196289,
            "timestamp": "2025-12-12T01:48:28.714Z",
            "unit": "°C"
          }
        }
      },
      "config": {
        "protocol": {
          "usb": true,
          "vcp": true
        }
      },
      "connections": {
        "usb": {
          "address": 20,
          "bus": 2,
          "product_id": "0504",
          "vendor_id": "289B"
        },
        "vcp": null
      },
      "info": {
        "firmware_version_major": 2,
        "firmware_version_minor": 4,
        "product": "VCP-RTD300-CAL",
        "serial": "E22377",
        "vendor": "Dracal technologies inc."
      },
      "model": "VCP-RTD300-CAL/v1"
    }
  },
  "products": {
    "VCP-RTD300-CAL/v1": {
      "channels": {
        "temperature": {
          "description": "Temperature",
          "details": {
            "virtual": false
          },
          "label": "temperature",
          "type": "Temperature",
          "unit": "°C"
        }
      },
      "info": {
        "interfaces": {
          "usb": "tenkiusb",
          "vcp": "tenkivcp"
        },
        "name": "VCP-RTD300-CAL",
        "sku": "605048",
        "vendor": "Dracal technologies inc."
      },
      "model": "VCP-RTD300-CAL/v1"
    }
  }
}

Advanced Examples

Get all channel names for a device

curl -s http://localhost:11395/3.6.0/devices/usb | jq ".devices[\"E22377\"].channel_list"
curl -s http://localhost:11395/3.6.0/devices/usb | jq '.devices["E22377"].channel_list'
curl -s http://localhost:11395/3.6.0/devices/usb | jq '.devices["E22377"].channel_list'

Example output:

[
  "temperature"
]

Get the full temperature value (magnitude, unit, timestamp)

curl -s http://localhost:11395/3.6.0/devices/usb | jq ".devices[\"E22377\"].channels.temperature.value"
curl -s http://localhost:11395/3.6.0/devices/usb | jq '.devices["E22377"].channels.temperature.value'
curl -s http://localhost:11395/3.6.0/devices/usb | jq '.devices["E22377"].channels.temperature.value'

Example output:

{
  "magnitude": 121.5538101196289,
  "timestamp": "2025-12-12T01:48:28.714Z",
  "unit": "°C"
}

Get the model identifier from a device

curl -s http://localhost:11395/3.6.0/devices/usb | jq ".devices[\"E22377\"].model"
curl -s http://localhost:11395/3.6.0/devices/usb | jq '.devices["E22377"].model'
curl -s http://localhost:11395/3.6.0/devices/usb | jq '.devices["E22377"].model'

Example output:

"VCP-RTD300-CAL/v1"

Get service information

curl -s http://localhost:11395/dracal-service-info | jq
curl -s http://localhost:11395/dracal-service-info | jq
curl -s http://localhost:11395/dracal-service-info | jq

Example output:

{
  "service_name": "dracal-device-service",
  "status": "ok",
  "version": {
    "major": 3,
    "minor": 5,
    "patch": 0,
    "tag": "v3.6.0-r1",
    "tweak": 0
  }
}