Querying sensor history - OnSight Knowledgebase

Querying sensor history

Back to API & integrations — Getting started Browse product

Use the Command history API to retrieve sensor values for selected assets over a specified period. Results are grouped into time intervals using the requested aggregation.

Existing API documentation

Open the Command public Swagger UI to browse the HTTP API and try supported operations. The public OpenAPI JSON is available for integration tooling.

The public documentation can be read without signing in. Executing protected API operations still requires a valid Command bearer token and the appropriate company, project and asset permissions. Public documentation omits operations restricted to SuperAdmin.

Administrator documentation

The same UI offers Admin API v1, the complete reference including SuperAdmin-only operations. Select Authorize, enter Bearer <your Command SuperAdmin access token>, then select Admin API v1.

The admin OpenAPI JSON requires an Authorization: Bearer <token> header. Missing or invalid credentials return 401; authenticated accounts without the SuperAdmin role receive 403. This requirement also applies in development.

Use the API host for your environment. On a standard local setup the UI is http://localhost:5001/apidefinition/index.html. The public document is for integration discovery; the Command application's generated client uses the full admin document.

Get an API token

Sign in to Command and open My profile, then scroll to API tokens. You can also reach My profile from your profile avatar. Give the integration a name, choose a 90, 180 or 365-day lifetime, and select Generate token. Copy and securely save the token when it is shown; it cannot be retrieved later.

Use Authorization: Bearer <your-api-token> for history requests. The token uses your account's current permissions. See Create and manage API tokens for the full workflow, Swagger authorisation, replacement and revocation.

Endpoint

GET /company/{companyId}/project/{projectId}/Asset/report/{startDate}/{endDate}/{intervalSeconds}
Authorization: Bearer {token}
Parameter Meaning
companyId, projectId Command company and project identifiers.
assetIds Command asset UUIDs. Repeat this query parameter for multiple assets.
sensorTypes Measurement types, such as Temperature and Humidity.
aggregations Min, Max, Median or Mean, paired by position with sensorTypes.
startDate, endDate Timestamps with an explicit timezone. Command normalises them to UTC.
intervalSeconds Aggregation interval in seconds.

Use an end after the start, a positive interval, and one aggregation for every sensor type.

Example request

The placeholders below must be replaced with your identifiers. The URL is shown on two lines for readability; send it as one URL.

/company/{companyId}/project/{projectId}/Asset/report/2026-10-12T00:00:00Z/2026-10-13T00:00:00Z/300
?assetIds={assetId}&sensorTypes=Temperature&aggregations=Mean

This requests five-minute mean temperature values.

Reading the response

The response contains startDate, endDate, interval and data. Each dataset contains assetId, assetName, hardwareId, sensorVaueType, aggregation and points. Each point contains a timestamp time and a nullable numeric value.

Preserve null readings as missing values; do not turn them into zero. Aggregated points do not reproduce every original live message.

Current contract details

The measurement field is currently spelled sensorVaueType. Use the exact field name returned by the API.

In the inspected implementation, the history response's hardwareId contains the underlying Core device ID. Live sensor updates use the Command hardware ID. Do not join these fields directly without mapping them.

History currently selects active asset–hardware associations and clips its query to the later of asset creation and association start, aligned to the report interval. This endpoint must not be treated as a complete history across previous probe assignments.

Review before publication

Validate the examples against the deployed Command version. Confirm date-boundary semantics, supported query sizes and retention with the service owner. The identifier mismatch described above reflects the inspected source and must be checked before relying on it as a long-term contract.

More in this category

Related guides for this topic.

Need a hand?

Tell us which product you use, what you’re trying to do, and what happened.

Contact support