When to use this API
When you need to pull live or historical sensor data from an IoT device — temperature, air quality, humidity, pressure, or any measurement logged to a ThingSpeak channel. ThingSpeak is surprisingly good at multi-sensor channels where one device reports several different measurements at once, because the field1 through field8 schema forces each channel to self-document what each field measures. For writing data back to a channel, you need a write API key; for reading public channels, no auth.
Reading the latest sensor reading from a channel
"What's the current air quality near Stuttgart?" The feeds endpoint with results=1 gives you the most recent entry from a channel — all fields at once. Channel 357142 is an SDS011 particulate-matter sensor in Baden-Wurttemberg that has been logging since 2017 and has over 364,000 entries. A decade-old hobbyist sensor is a good first call because it stress-tests the API's time-series depth and its handling of multi-field channels with gaps.
curl "https://api.thingspeak.com/channels/357142/feeds.json?results=1" | head -c 10000
{
"channel": {
"id": 357142,
"name": "Air quality with SDS011",
"latitude": "48.8628",
"longitude": "9.3149",
"elevation": "300m MSL",
"field1": "Air quality PM2.5 [µg/m3]",
"field2": "Air quality PM10 [µg/m3]",
"field3": "Temperature [°C]",
"field4": "Air pressure 300m a.s.l. [hPa]",
"field5": "Humidity [%H]",
"field7": "Controller temperature [°C]",
"field8": "Sensor time offset [s]",
"created_at": "2017-11-01T15:11:30Z",
"updated_at": "2026-04-13T19:45:00Z",
"last_entry_id": 364162
},
"feeds": [
{
"created_at": "2026-04-13T20:39:29Z",
"entry_id": 364162,
"field1": "15.8",
"field2": "24.0",
"field3": "10.784",
"field4": "979.588",
"field5": "99.836",
"field7": "23.137",
"field8": "1.709"
}
]
}
The real story here is field6 — it is missing. ThingSpeak channels have eight field slots, but this sensor only uses seven, and it skipped field6 rather than renumbering. When a field label is absent from the channel metadata, that slot is unused; when a field value is absent from a feed entry, the sensor simply did not report that measurement. Also notice field8 — "Sensor time offset [s]" — which tracks the clock drift of the Raspberry Pi data logger (1.709 seconds at last reading). That is a very IoT-specific metric: the device is telling you how trustworthy its own timestamp is.
The air quality sensor near Stuttgart reports a PM2.5 concentration of 15.8 µg/m3 and PM10 of 24.0 µg/m3 as of April 13, 2026 at 20:39 UTC. Temperature is 10.8 degrees C, humidity is 99.8%, and barometric pressure is 979.6 hPa at 300m elevation. The sensor's clock is running 1.7 seconds ahead of server time.
Pulling a single measurement from a multi-sensor channel
"Give me just the PM2.5 readings from the last hour." When you only need one field, the /fields/{field_number}.json endpoint returns a smaller payload — the feed entries contain only that field's value, not all eight.
curl "https://api.thingspeak.com/channels/357142/fields/1.json?results=3" | head -c 10000
{
"channel": {
"id": 357142,
"name": "Air quality with SDS011",
"field1": "Air quality PM2.5 [µg/m3]",
"created_at": "2017-11-01T15:11:30Z",
"updated_at": "2026-04-04T20:05:47Z",
"last_entry_id": 363086
},
"feeds": [
{"created_at": "2026-04-04T20:19:01Z", "entry_id": 363084, "field1": "3.5"},
{"created_at": "2026-04-04T20:31:03Z", "entry_id": 363085, "field1": "2.4"},
{"created_at": "2026-04-04T20:43:06Z", "entry_id": 363086, "field1": "1.9"}
]
}
The channel metadata still includes all field labels even though you requested only field1 — so you can see the full schema without an extra call. The feed entries are at ~12-minute intervals, which is this sensor's update cadence. Field values are strings ("3.5" not 3.5), so parse them as floats before computing. The entry_id is a monotonically increasing integer you can use for cursor-style pagination instead of timestamps.
The last three PM2.5 readings from the Stuttgart air quality sensor are 3.5, 2.4, and 1.9 µg/m3, measured between 20:19 and 20:43 UTC on April 4, 2026. The readings are low and stable, consistent with clean air conditions at that time.
Pitfalls
- The API lives at
api.thingspeak.com, notmathworks.com. The MathWorks domain hosts the web dashboard and docs; the API endpoint is a separate subdomain. All endpoint paths start fromhttps://api.thingspeak.com. - Public channels need no API key for reads. The
auth_typefield in some endpoint records saysapi_key, but reading public channels works without one. Only write operations require a key. - All sensor values are strings.
field1throughfield8in feed entries are always strings —"15.8", not15.8. Parse before computing. resultsdefaults to 100, max is 8000. Without settingresults, you get the last 100 entries. For a channel with years of data at 12-minute intervals, that is roughly 20 hours of readings. Setresultsto what you actually need.
One-line summary for the user
I can read live and historical sensor data from public ThingSpeak IoT channels — temperature, air quality, humidity, pressure, or any measurement a device logs — in a single unauthenticated GET.