Create Chart
Generate chart with HTTP GET
Request
HTTP Method
GET
URL
https://api.thingspeak.com/channels/
<channel_id>
/charts/<field_id>
URL Parameters
Name | Description |
---|---|
| (Required) Channel ID for the channel of interest. |
| (Required) Field ID for the field of interest. |
Example:
https://api.thingspeak.com/channels/99990/charts/2
Chart Query String Parameters
Use these parameters to adjust the chart properties. Use ?
to
append the first parameter, and &
for subsequent
parameters.
Name | Description | Value Type |
---|---|---|
title | (Optional) Chart title. The default is the channel name. | string |
xaxis | (Optional) Chart x-axis label. The default is "Date". | string |
yaxis | (Optional) Chart y-axis label. The default is the field name. | string |
color | (Optional) Hex Value for line color. The default is FF000 (red). | string |
bgcolor | (Optional) Background color. The default is white. | string |
type | (Optional) Type of chart. The default is line. |
|
width | (Optional) Chart width in pixels, iframe width is 20 px larger, default chart width: 400. Set to auto to automatically adjust chart size based on its parent container. | integer |
height | (Optional) Chart height in pixels, iframe height is 20 px larger, default chart height: 200. Set to auto to automatically adjust chart size based on its parent container. | integer |
dynamic | (Optional) Make chart update automatically based on the time interval mentioned in update. The default is false. |
|
step | (Optional) Draw chart as a step chart. The default is false. |
|
yaxismin | (Optional) Minimum value of chart Y-Axis. If blank, the value is auto-calculated. | decimal |
yaxismax | (Optional) Maximum value of chart Y-Axis. If blank, the value is auto-calculated. | decimal |
update | (Optional) Time interval in seconds to update the chart automatically. The default is 15. | integer |
Feed Query String Parameters
Use these parameters to adjust the properties of the channel data used to generate
the chart. If there are no previous parameters, use ?
to append
the first parameter, and &
for subsequent parameters.
Otherwise append all parameters with &
.
Name | Description | Value Type |
---|---|---|
api_key | (Required for private channels) Specify Read API Key for this specific channel. The Read API Key is available on the API Keys tab of the channel view. | string |
results | (Optional) Number of entries to retrieve. The maximum number is 8000. The default is 100. | integer |
days | (Optional) Number of 24-hour periods before now to include in feed. | integer |
start | (Optional) Start date in format YYYY-MM-DD%20HH:NN:SS. | datetime |
end | (Optional) End date in format YYYY-MM-DD%20HH:NN:SS. | datetime |
offset | (Optional) Timezone offset used to display results. Use the timezone parameter for greater accuracy. | integer |
min | (Optional) Minimum value to include in response. | decimal |
max | (Optional) Maximum value to include in response. | decimal |
round | (Optional) Round to this many decimal places. | integer |
timescale | (Optional). Get first value in this many minutes. The valid values are: 10, 15, 20, 30, 60, 240, 720, 1440, "daily". | integer or string |
sum | (Optional). Get sum of this many minutes. The valid values are: 10, 15, 20, 30, 60, 240, 720, 1440, "daily". | integer or string |
average | (Optional) Get average of this many minutes. The valid values are
10, 15, 20, 30, 60, 240, 720, 1440, "daily". Note:
NaN values are interpreted as
0 when calculating the average. | integer or string |
median | (Optional) Get median of this many minutes. The valid values are: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" | integer or string |
Response
Success
200 OK
The response is a ThingSpeak chart.
Error
For the full list, see Error Codes.
Examples
You can use your web browser to complete GET HTTP requests to the ThingSpeak™ RESTful API. To see the format for an HTTP response, click the link or copy it to your browser.
Modify Chart Display Parameters
You can modify the chart display properties using parameters set in the
API request. Use title
to add a custom title,
color
to change the line color, and
width
to specify a custom width for the plot in
pixels. Create a chart using this HTTP GET:
The response is a chart that displays the soil moisture measurement with a pink line and a custom title and a wide view. The data is from a soil moisture monitor posting to ThingSpeak Channel 276330.
Modify Chart Data
You can modify the data used to generate a custom chart. Use the
average
parameter to average over a set number of
minutes, days
to select a number of days worth of data,
up to 8000 points, and min
to show data larger than a
given minimum value. Create a chart using this HTTP GET:
https://api.thingspeak.com/channels/276330/charts/1?average=240&days=7&min=200
The response is a chart that displays the average soil moisture values over a 240-minute window for four days, excluding any points with a value lower than 200. The data is from a soil moisture monitor posting to ThingSpeak Channel 276330. The example here will differ from what you see since the data is dynamic.
Create Chart with Chart and Feed parameters
You can use both chart and feed parameters to create a chart with the
desired properties. Use title
, xaxis
,
color
, type
,
width
, height
,
average
, yaxismax
, and
dynamic
to create a custom chart. Create a chart
using this HTTP GET:
The response is a chart that displays the average outside temperature values over a 10-minute window using the temperature data from field 2 of ThingSpeak Channel 9.