Main Content

Read Data

Read data from all fields in channel with HTTP GET

Request

HTTP Method

GET

URL

https://api.thingspeak.com/channels/<channel_id>/feeds.<format>

URL Parameters

NameDescription

<channel_id>

(Required) Channel ID for the channel of interest.

<format>

(Required) Format for the HTTP response, specified as json, xml, or csv.

Example: https://api.thingspeak.com/channels/266256/feeds.json

Query String Parameters

NameDescriptionValue Type
api_key

(Required for private channels). Specify Read API Key for this specific channel. The Read API Key is found on the API Keys tab of the channel view.

string

results

(Optional) Number of entries to retrieve. The maximum number is 8,000.

integer

days

(Optional) Number of 24-hour periods before now to include in response. The default is 1.

integer

minutes(Optional) Number of 60-second periods before now to include in response. The default is 1440.

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

timezone

(Optional) Identifier from Time Zones Reference for this request.

string

offset

(Optional) Timezone offset that results are displayed in. Use the timezone parameter for greater accuracy.

integer

status

(Optional) Include status updates in feed by setting "status=true".

true or false

metadata

(Optional) Include metadata for a channel by setting "metadata=true".

true or false

location

(Optional) Include latitude, longitude, and elevation in feed by setting "location=true".

true or false

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, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily".

integer or string

sum

(Optional) Get sum of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily".

integer or string

average

(Optional) Get average of this many minutes, valid values: 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, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily".

integer or string

Tip

The results parameter has the highest precedence. Using results with the parameters min, max, timescale, sum, average, or median can cause less than 8000 records to be returned. The results parameter determines the maximum number of entries to be used for a query, up to 8000. For example, consider a channel with one update per minute. A read request to that channel with the parameters ?results=120&sum=60 returns only two records, and not 120. See the example Read Two Hours of Entries in JSON Format and Average.

Examples

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.

Read Three Entries in JSON Format

Channel 9 contains information from several home environment sensors. You can read data from this public channel. The format for the response occurs at the end of the URL, before any query string parameters. Append the first parameter after a question mark ?. You can use the results parameter to control the number of entries returned, which is up to 8000.

https://api.thingspeak.com/channels/9/feeds.json?results=3

Read Two Hours of Entries in JSON Format and Average

Channel 9 contains information from several home environment sensors, updates once per minute. You can read data from this public channel. The format for the response occurs at the end of the URL, before any query string parameters. Append the first parameter after a question mark ?. You can use the results parameter to control the number of entries returned, up to 8000. In this request, 120 results are averaged into two responses.

https://api.thingspeak.com/channels/9/feeds.json?results=120&average=60

Read Four Entries in XML Format

In this example, the format is specified as XML. The results parameter is used to return a set number of entries, in this case four. The first parameter is appended after a question mark ?.

https://api.thingspeak.com/channels/9/feeds.xml?results=4

Read Five Entries from a Private Channel in JSON Format

To read data from a private channel, supply the Read API Key with the parameter api_key. Append the first parameter after a question mark ?. Append the second parameter after an ampersand &. In this case, results is used to request five results.

https://api.thingspeak.com/channels/9/feeds.json?api_key=E52AWRAV1RSXQQJW&results=5

Read a Date Range of Events in CSV Format

When you request the output in csv format, the file returned is a comma-separated variable format. Depending on your computer configuration, your browser can start additional software to display this format. In this example, the start and end parameters are used to specify date limits for the requested data.

https://api.thingspeak.com/channels/9/feeds.csv?start=2011-11-11%2010:10:10&end=2011-11-11%2011:11:11

Response

Success

HTTP Status Code

200 OK

Body

 JSON Example

 XML Example

 CSV Example

Error

For the full list, see Error Codes.

If you do not have access to the channel, the response is -1.