Skip to content

Device API integration guide ​

Use a BLSFlow personal token to read devices in your account from a monitoring script, an operations system, or an MCP client. The summary view covers device status, CPU model, memory module summary, basic details, current hashrate, and the reported running project. Grant full read access to programs that need detailed inventory, BMC connection details, or diagnostics.

Quickstart ​

1. Create a personal token ​

  1. Sign in to the BLSFlow console and select API Token from the account menu in the top right.
  2. Select Create token. Name it after the program that will use it, such as “Device monitor,” and choose a lifetime or Never expires.
  3. Copy the full token, starting with blsf_pat_, and save it in your secrets manager. The full value appears once. After you close the dialog, the list shows the first 10 characters after the prefix so you can identify the token. Older tokens without a preview show —.
Permission at creationData you can read
Read devices (devices:read)Summary view with CPU model, memory module summary, and basic details. Existing read-only tokens keep this permission
Read full device data (devices:read_full)Summary and full views, including device IPs, BMC connection metadata, hardware inventory, and structured diagnostics

2. Make your first request ​

The API base URL is https://api.blsflow.com/api/open/v1. Use HTTPS and pass Authorization: Bearer <full-token> with each request.

In Bash, run the following commands. The terminal prompts for the full token without displaying what you enter. If your secrets manager already sets the environment variable, run the curl command directly.

bash
read -r -s -p 'BLSFlow API Token: ' BLSFLOW_DEVICE_TOKEN
printf '\n'
export BLSFLOW_DEVICE_TOKEN

curl --silent --show-error --fail-with-body \
  -H "Authorization: Bearer $BLSFLOW_DEVICE_TOKEN" \
  'https://api.blsflow.com/api/open/v1/machines?status=online'

A successful request returns HTTP 200 and JSON. Use an items[].id value from the list to request device details.

json
{
  "items": [
    {
      "id": "42",
      "code": "0123456789abcdef0123456789abcdef",
      "hostname": "rig-42",
      "status": "online",
      "cpu_model": "AMD EPYC 7443P",
      "memory_summary": {
        "capacity_gib": 64,
        "installed_count": 4,
        "slot_count": 8,
        "speeds": ["3200 MT/s"],
        "configured_speeds": ["2666 MT/s"]
      },
      "last_seen_at": "2026-11-27T08:00:00Z",
      "hashrate_khs": 12.5,
      "hashrate_sampled_at": "2026-11-27T08:00:04Z",
      "current_project": { "code": "xmr", "name": "Monero" }
    }
  ],
  "page": 1,
  "per_page": 50,
  "total": 1
}

An "items": [] response means that page has no matching devices. Remove status=online to check for devices that are offline or in maintenance.

HTTP API ​

The paths below are relative to the API base URL.

Use caseRequest
List devicesGET /machines
List only online devicesGET /machines?status=online
Get a deviceGET /machines/{id}

List devices and paginate ​

Query parameterAccepted valuesDefault
statusonline or offlineAll statuses when omitted
pageInteger from 1 to 1,000,0001
per_pageInteger from 1 to 20050
viewsummary or fullsummary

Devices are sorted by ID in descending order. The response contains the page’s items, its page and per_page, and the filtered total. Keep the filter and page size constant across requests. Stop when the page is empty or page × per_page ≥ total. Device status can change between requests. Use id to merge records when polling.

Get device details ​

Replace 42 with the device ID returned by the list.

bash
curl --silent --show-error --fail-with-body \
  -H "Authorization: Bearer $BLSFLOW_DEVICE_TOKEN" \
  'https://api.blsflow.com/api/open/v1/machines/42'

The response is one device object with all list item fields, plus system and hardware information and the latest resource and power samples. Both endpoints support view=full.

Device fields ​

FieldTypeMeaning
idStringDevice ID for detail requests and merging records
codeStringDevice code
hostnameString or nullHost name
cpu_modelString or nullCPU model, available in the list for grouping devices
memory_summaryObject or nullPhysical memory module (DIMM) summary, included in both views
statusStringonline, offline, or maintenance
last_seen_atTimestamp or nullMost recent device heartbeat
hashrate_khsNumber or nullCurrent hashrate in kH/s
hashrate_sampled_atTimestamp or nullTime the current hashrate sample was reported
current_projectObject or nullReported running project with a code and a nullable name

Timestamps use ISO 8601 in UTC with a Z suffix. A zero reading from an online device with a valid miner report within the past 10 seconds appears as 0. Hashrate and current project are null if the device is offline, the sample is missing or stale, or it predates or coincides with a successful stop.

Read items[].memory_summary in the list or memory_summary in device details. Both use this structure.

FieldMeaning
capacity_gibTotal physical capacity of installed modules in GiB, or null if unknown
installed_countNumber of installed modules, null if unknown, or 0 if all reported slots are empty
slot_countNumber of reported slots, including empty slots
speedsDistinct rated speeds of installed modules, with original units. Older agents may have used the configured rate when the rated speed was missing. Returns [] when there are no valid readings
configured_speedsDistinct operating rates configured by the firmware for installed modules, with original units. Returns [] until a valid rate has been reported

When usable DIMM records are unavailable, memory_summary is null. In device details, memory_gb is the total memory recognized by the operating system.

Device details also include these fields.

FieldMeaning
os_name, agent_versionOperating system and Agent version. Both can be null
cpu_count, memory_gb, disk_gbLogical CPUs available to the agent, total memory (GiB), and total disk space (GiB)
resourcesLatest system sample with sampled_at, cpu_percent (%), memory_used_mb (MiB), disk_used_gb (GiB), and cpu_temperature_c (°C)
powerLatest power sample with sampled_at and watts (W)

resources, power, and their sample values can be null. Use each object’s sampled_at to decide whether the sample is recent enough for your use case.

Full device fields ​

Create a token with Read full device data and set view=full in the request. For example, use GET /machines?status=online&view=full for a full online list or GET /machines/42?view=full for full detail. Use the same API base URL and Bearer header.

The full list includes these fields in addition to the summary.

DataFields
Device inventoryserial_no, remark, os_name, agent_version, agent_version_outdated, seat_status. The paginated response also includes agent_target_version
Hardware and groupscpu_num (logical CPUs), memory_size and disk_size (GiB), cluster_id, tag_ids, tags
Latest sampleslast_report_at, latest_metric_at, latest_power_watts, latest_cpu_rate, latest_used_memory_mb, latest_used_disk_gb, latest_temperature, latest_memory_usage_percent, latest_disk_usage_percent
Latest miner snapshotlatest_hashrate_khs, latest_hashrate_at, latest_hashrate_coin. Use the summary’s hashrate_khs and current_project for current runtime state
Network and BMCpublic_ip, private_ip, mgmt_user, mgmt_password_set, bmc_host, bmc_port, bmc_verify_status. mgmt_password_set is a flag indicating whether a password is configured

Full detail also includes mac, network_card_name, cluster, deployment_at, last_offline_at, runtime_seconds, today_power_kwh, and last_24h_power_kwh. hardware groups inventory by component type. Each record has an info array with the recognized attributes for each component, such as one entry per CPU socket. With no recognized attributes, info is empty. resource_utilization contains resource usage summaries.

For DIMMs, each info entry uses speed and configured_speed for rated and operating speeds. configured_speed is available after an upgraded agent reports its hardware. An empty string indicates the snapshot did not contain a configured speed.

sel_snapshot reports the latest collection state and recognized events. Each bmc_datetime gives the local time reported by the BMC without a time zone. hardware_monitor_snapshot provides structured CPU, memory, disk, fan, and power-supply readings. Raw diagnostic output and credentials stay in the console.

Python example ​

This script uses the Python standard library to read online devices across all pages. Set BLSFLOW_DEVICE_TOKEN before running it.

python
import json
import os
from urllib.parse import urlencode
from urllib.request import Request, urlopen

BASE_URL = "https://api.blsflow.com/api/open/v1"
TOKEN = os.environ["BLSFLOW_DEVICE_TOKEN"]


def online_devices():
    page = 1
    per_page = 100
    while True:
        query = urlencode({"status": "online", "page": page, "per_page": per_page})
        request = Request(
            f"{BASE_URL}/machines?{query}",
            headers={"Authorization": f"Bearer {TOKEN}", "Accept": "application/json"},
        )
        with urlopen(request, timeout=15) as response:
            result = json.load(response)

        yield from result["items"]
        if not result["items"] or page * per_page >= result["total"]:
            return
        page += 1


online_count = 0
cpu_models = set()
for device in online_devices():
    online_count += 1
    if device["cpu_model"]:
        cpu_models.add(device["cpu_model"])
    project = device["current_project"] or {}
    print(device["id"], device["hostname"], device["hashrate_khs"], project.get("code"))

print(f"{online_count} online devices, {len(cpu_models)} known CPU models")

Errors and retries ​

Use the HTTP status and the response’s error_code to handle failures. Here is an example rate limit response body.

json
{ "success": false, "error_code": "RATE_LIMITED", "message": "Too many requests" }
HTTP statuserror_codeWhat to do
400VALIDATION_ERRORCheck view, the status filter, page number, and page size
401UNAUTHORIZEDCheck that the Authorization header contains the full token and that the token is still valid
403PERMISSION_DENIEDUse a token with full device read access when requesting view=full
404RESOURCE_NOT_FOUNDGet the device ID again from the current account’s list
429RATE_LIMITEDWait for the number of seconds in Retry-After before retrying
503SERVICE_UNAVAILABLEWait briefly and retry a limited number of times

HTTP and MCP share rate limits. By default, both a 120-request limit per token per minute and a 600-request limit per account per minute apply. For polling, fetch devices in pages and request details when you need hardware or resource data.

MCP integration ​

Use an MCP client that supports Streamable HTTP and custom Bearer credentials. Connect it to https://mcp.blsflow.com/mcp/devices. Set Authorization: Bearer <full-token> in the client’s credential settings. Tool arguments contain filters or a device ID.

To connect Codex CLI, set BLSFLOW_DEVICE_TOKEN in your terminal and run the following command.

bash
codex mcp add blsflow-devices \
  --url https://mcp.blsflow.com/mcp/devices \
  --bearer-token-env-var BLSFLOW_DEVICE_TOKEN

Start Codex from the same environment. Ask it to list online devices with their hashrate and current project, then request details using a device ID from that list.

ToolExample argumentsResult
list_devices{"status":"online","page":1,"per_page":50}The same paginated data as the HTTP device list
get_device{"id":"42"}The same device object as the HTTP detail endpoint

Both tools accept view: "full". To count CPU models among online devices, page through list_devices and group the returned rows by cpu_model.

If you’re writing an MCP client, read the data from the tool result’s structuredContent field. A tool that hits the rate limit returns RATE_LIMITED and retry_after_seconds. If the connection returns 401, check that the environment variable is available to the client and contains the full, valid token.

Rotate and revoke tokens ​

Create a separate token for each program so you can rotate credentials independently. Create a replacement, update the program’s secret configuration, and confirm requests work before revoking the old token in the API Token list. HTTP and MCP reject revoked tokens on the next request, including tokens that never expire.

Store the full value in a secrets manager or environment variable. Keep it out of repositories, URLs, logs, and chats. If a token is exposed, revoke it and create a replacement.