Read Field
Read data from single field of channel with HTTP GET
Request
HTTP Method
GET
URL
https://api.thingspeak.com/channels/
<channel_id>
/fields/<field_id>
.<format>
URL Parameters
Name | Description |
---|---|
| (Required) Channel ID for the channel of interest, specified as an integer. |
| (Required) Field ID for the channel of interest. |
| (Required) Format for the HTTP response, specified as
|
Example:
https://api.thingspeak.com/channels/266256/fields/2.json
Query String Parameters
Name | Description | Value 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 8000. | 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". |
|
metadata | (Optional) Include metadata for a channel by setting "metadata=true". |
|
location | (Optional) Include latitude, longitude, and elevation in feed by setting "location=true". |
|
min | (Optional) Minimum value to include in response. |
|
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:
| integer or string |
median | (Optional) Get median of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily". | integer or |
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 10 Results in JSON Format
Channel 9 contains information from several home environment sensors. You
can read data from the individual fields of this public channel. The format
for the response occurs at the end of the URL, before any query string
parameters. Here the requested format is json
. 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/fields/1.json?results=10
Read Median Value every 10 Minutes for 100 Results in XML Format
In this example, the format is specified as XML. The results parameter is used to return a specified number of entries, in this case 10.
https://api.thingspeak.com/channels/9/fields/2.xml?results=100&median=10
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 open additional software to display this
format. Use the ampersand &
to append the second
parameter. In this example, the start
and
end
parameters are used to specify date limits for
the requested data.
Read One Day of Results in Text Format
https://api.thingspeak.com/channels/9/fields/1?api_key=E52AWRAV1RSXQQJW
ThingSpeak returns the last day of data, up to 8000 points, when no other parameter is specified.
Response
Success
200 OK
If you do not have access to the channel, the response is -1.
Error
For the full list, see Error Codes.
If you do not have access to the channel, the response is -1.