Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Create Chart

Generate a chart with HTTP GET

Request

HTTP Method

GET

URL

https://api.thingspeak.com/channels/<channel_id>/charts/<field_id>

URL Parameters

NameDescription

<channel_id>

(Required) Channel ID for the channel of interest.

<field_id>

(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.

NameDescriptionValue-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) Line color. The default is red.

<string>

bgcolor

(Optional) Background color. The default is white.

<string>

type

(Optional) Type of chart. The default is line.

<line/bar/column/spline>

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.

<true/false>

step(Optional) Draw chart as a step chart. The default is false.<true/false>
export(Optional) Show export buttons, so that chart can be saved as an image. The default is false.<true/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 yused 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 &.

NameDescriptionValue-Type
api_key

(Required) Specify User API key. This is different from a channel API key, and can be found on your profile page.

<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".<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

HTTP Status Code

200 OK

Body

The response is a ThingSpeak chart.

Error

For the full list, see Error Codes.

Examples

collapse all

You can use your web browser to complete GET HTTP requests to the RESTful API for ThingSpeak™. To see the format for an HTTP response, click the link or copy it to your browser.

You can use both chart and feed parameters to create a chart with the desired properties.

Create a chart using this HTTP GET:

https://api.thingspeak.com/channels/9/charts/2?title=Outside%20Ambient%20Temperature&xaxis=Time&yaxis=Average%20Temperature%20%5BF%5D&color=blue&type=column&width=500&height=500&average=10&yaxismax=100&dynamic=true

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.