ThingSpeak Charts API

Using the ThingSpeak charts API, you can visualize numeric data stored in ThingSpeak channels. Supported chart types are:
  • Line
  • Bar
  • Column
  • Spline
  • Step
Options include size, color, and labels.

Create a Chart

To create a chart, go to the following URL, replacing CHANNEL_ID and FIELD_ID with values from one of your Channels.

http://api.thingspeak.com/channels/CHANNEL_ID/charts/FIELD_ID

Chart parameters

  • title (string) Chart title, default: Channel name (optional)
  • xaxis (string) Chart's x-axis label, default: "Date" (optional)
  • yaxis (string) Chart's y-axis label, default: field name (optional)
  • color (string) Line color, default: red (optional)
  • bgcolor (string) Background color, default: white (optional)
  • type (line/bar/column/spline) Type of chart, default: line (optional)
  • width (integer) Chart width in pixels, iframe width will be 20px larger, default chart width: 400. Set to auto to automatically adjust chart size based on its parent container. (optional)
  • height (integer) Chart height in pixels, iframe height will be 20px larger, default chart height: 200. Set to auto to automatically adjust chart size based on its parent container. (optional)
  • dynamic (true/false) Make chart update automatically every 15 seconds, default: false (optional)
  • step (true/false) Draw chart as a step chart, default: false (optional)
  • export (true/false) Show export buttons, so that chart can be saved as an image, default: false (optional)
  • yaxismin (decimal) Minimum value of chart's Y-Axis; if blank the value is auto-calculated (optional)
  • yaxismax (decimal) Maximum value of chart's Y-Axis; if blank the value is auto-calculated (optional)

Feed parameters

  • api_key (string) Read API Key for this specific Channel (optional--no key required for public channels)
  • results (integer) Number of entries to retrieve, 8000 max, default of 100 (optional)
  • days (integer) Number of 24-hour periods before now to include in feed (optional)
  • start (datetime) Start date in format YYYY-MM-DD%20HH:NN:SS (optional)
  • end (datetime) End date in format YYYY-MM-DD%20HH:NN:SS (optional)
  • timezone (string) Timezone identifier for this request (optional)
  • offset (integer) Timezone offset that results should be displayed in. Please use the timezone parameter for greater accuracy. (optional)
  • status (true/false) Include status updates in feed by setting "status=true" (optional)
  • location (true/false) Include latitude, longitude, and elevation in feed by setting "location=true" (optional)
  • min (decimal) Minimum value to include in response (optional)
  • max (decimal) Maximum value to include in response (optional)
  • round (integer) Round to this many decimal places (optional)
  • timescale (integer or string) Get first value in this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)
  • sum (integer or string) Get sum of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)
  • average (integer or string) Get average of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)
  • median (integer or string) Get median of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)
You cannot use results parameter in combination with timescale, sum, average, or median.

Embed a Chart

Use the chart API as an iframe to embed ThingSpeak charts on your web page.

Chart Embed Code

<iframe width="450" height="250" style="border: 1px solid #cccccc;" src="http://thingspeak.com/channels/CHANNEL_ID/charts/FIELD_ID"></iframe>

Example of Chart

Embed Dynamic Chart

To place a dynamic ThingSpeak Chart on your webpage, use the Chart API as the source of an iframe and add the chart parameter ”dynamic=true”.

Chart Embed Code

<iframe width="450" height="250" style="border: 1px solid #cccccc;" src="http://thingspeak.com/channels/CHANNEL_ID/charts/FIELD_ID?dynamic=true"></iframe>

Example of Chart