Back to all

How to get minute by minute temperature readings for one or more sensors through API

The API example web page fails and returns NULL for a temperature readings for my sensors. The "Try It" curl command returns a successful 200 status, but the temperature values are NULL.

Request:

curl --request POST \
     --url https://api.samsara.com/v1/sensors/history \
     --header 'accept: application/json' \
     --header 'authorization: Bearer XXXXXX' \
     --header 'content-type: application/json' \
     --data '
{
  "fillMissing": "withNull",
  "series": [
    {
      "field": "probeTemperature",
      "widgetId": 281474978115162
    },
    {
      "field": "ambientTemperature",
      "widgetId": 281474978115159
    }
  ],
  "startMs": 1761256494000,
  "endMs": 1761260094000,
  "stepMs": 60000
}
'

Response of the form:

{
  "results": [
    {
      "timeMs": 1761256494000,
      "series": [
        null,
        null
      ]
    },
    {
      "timeMs": 1761256554000,
      "series": [
        null,
        null
      ]
    },

The sensors are working. I can download the temperature values for individual temperature probes through the web UI. I am trying to download the same values for one or ideally more temperature probes via the API to remove a tedious and error prone manual process.