Main Content

Read Last Field Entry

Read last entry in channel field with HTTP GET

Request

HTTP Method

GET

URL

https://api.thingspeak.com/channels/<channel_id>/fields/<field_id>/last.<format>

URL Parameters

NameDescription

<channel_id>

(Required) Channel ID for the channel of interest.

<field_id>

(Required) Field ID for the field of interest.

<format>

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

Example: https://api.thingspeak.com/channels/266256/fields/2/last.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

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

location

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

true or false

prepend

(Optional) Text to add before the API response.

string
append

(Optional) Text to add after the API response.

string

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 Last Entry 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. This example returns the last entry from channel 9 in JSON format.

https://api.thingspeak.com/channels/9/fields/2/last.json

Read Last Entry including Location in XML Format

When you include the offset parameter, ThingSpeak returns the time data with the specified offset from GMT. Append the first parameter after a question mark ?. This request returns the results in XML format.

https://api.thingspeak.com/channels/9/fields/2/last.xml?offset=3

Read Last Entry Including Status From a Private Channel 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. Reading from a private channel requires the read API Key. Use the query string parameter api_key to specify the API Key. Each entry also has a status field. In this example, status=true returns the channel status entry for the last field along with the feed data. Append the second parameter after the ampersand &.

https://api.thingspeak.com/channels/9/fields/2/last.csv?api_key=E52AWRAV1RSXQQJW&status=true

Response

Success

HTTP Status Code

200 OK

Body

 Text Example

 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.