ThingSpeak API
api.thingspeak.com · Developer Tools
IoT analytics platform by MathWorks — store, visualize, and analyze IoT sensor data in real time. Free tier: up to 3M messages/year, 3-second update interval.
Authentication
API Key
Channel-specific read/write API keys from thingspeak.mathworks.com. Public channels can be read without a key.
Sample Requests
GET
Read channel data
Read the last 5 entries from public channel 9 (wind speed data).
https://api.thingspeak.com/channels/9/feeds.json?results=5
Hover any highlighted part to learn what it does
curl -X GET "https://api.thingspeak.com/channels/9/feeds.json?results=5"
import requests
params = {
"results": "5"
}
response = requests.get(
"https://api.thingspeak.com/channels/9/feeds.json",
params=params,
)
print(response.json())const url = new URL('https://api.thingspeak.com/channels/9/feeds.json');
url.searchParams.set('results', '5');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.thingspeak.com/channels/9/feeds.json")
q := baseURL.Query()
q.Set("results", "5")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.thingspeak.com/channels/9/feeds.json")
uri.query = URI.encode_www_form({
"results" => "5"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.thingspeak.com/channels/9/feeds.json?" . http_build_query([
"results" => "5"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
Write sensor data
Write temperature and humidity readings to your channel.
https://api.thingspeak.com/update?field1=23.5&field2=65&api_key=YOUR_WRITE_KEY
Hover any highlighted part to learn what it does
curl -X GET "https://api.thingspeak.com/update?field1=23.5&field2=65&api_key=YOUR_WRITE_KEY"
import requests
params = {
"field1": "23.5",
"field2": "65",
"api_key": "YOUR_WRITE_KEY"
}
response = requests.get(
"https://api.thingspeak.com/update",
params=params,
)
print(response.json())const url = new URL('https://api.thingspeak.com/update');
url.searchParams.set('field1', '23.5');
url.searchParams.set('field2', '65');
url.searchParams.set('api_key', 'YOUR_WRITE_KEY');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.thingspeak.com/update")
q := baseURL.Query()
q.Set("field1", "23.5")
q.Set("field2", "65")
q.Set("api_key", "YOUR_WRITE_KEY")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.thingspeak.com/update")
uri.query = URI.encode_www_form({
"field1" => "23.5",
"field2" => "65",
"api_key" => "YOUR_WRITE_KEY"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.thingspeak.com/update?" . http_build_query([
"field1" => "23.5",
"field2" => "65",
"api_key" => "YOUR_WRITE_KEY"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Create a free account at thingspeak.mathworks.com
- Create a channel and get your Write API Key
- Write: GET /update?api_key=YOUR_KEY&field1=VALUE
- Read: GET /channels/{id}/feeds.json?results=10
- Public channels need no key to read