ThingSpeak

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Get a Channel Field Feed

View a Channel Field Feed

To view a channel field feed, send an HTTP GET, replacing CHANNEL_ID with the ID of your channel and FIELD_ID with the ID of your field.

Valid parameters:

  • api_key (string) Read API key for this specific channel (optional--no key required for public channels)

  • results (integer) Number of entries to retrieve, 8000 max (optional)

  • days (integer) Number of 24-hour periods before now to include in feed, default 1 (optional)

  • start (datetime) Start date in format YYYY-MM-DD%20HH:NN:SS (optional)

  • end (datetime) End date in format YYYY-MM-DD%20HH:NN:SS (optional)

  • timezone (string) Identifier from Time Zones Reference for this request (optional)

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

  • status (true/false) Include status updates in feed by setting "status=true" (optional)

  • metadata (true/false) Include metadata from a channel by setting "metadata=true" (optional)

  • location (true/false) Include latitude, longitude, and elevation in feed by setting "location=true" (optional)

  • min (decimal) Minimum value to include in response (optional)

  • max (decimal) Maximum value to include in response (optional)

  • round (integer) Round to this many decimal places (optional)

  • timescale (integer or string) Get first value in this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)

  • sum (integer or string) Get sum of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)

  • average (integer or string) Get average of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)

  • median (integer or string) Get median of this many minutes, valid values: 10, 15, 20, 30, 60, 240, 720, 1440, "daily" (optional)

  • callback (string) Function name to be used for JSONP cross-domain requests (optional)

    Note:   The results parameter is not compatible with timescale, sum, average, or median.

JSON

To view a channel field feed, send an HTTP GET to https://api.thingspeak.com/channels/CHANNEL_ID/fields/FIELD_ID.json, replacing CHANNEL_ID with the ID of your channel and FIELD_ID with the ID of your field.

Example GET:

The response is a JSON object of the channel field feed, for example:

{
  "channel":
  {
    "id": 9,
    "name": "my_house",
    "description": "Netduino Plus connected to sensors around the house",
    "latitude": "40.44",
    "longitude": "-79.996",
    "field1": "Light",
    "field2": "Outside Temperature",
    "created_at": "2010-12-13T20:20:06-05:00",
    "updated_at": "2014-02-26T12:43:04-05:00",
    "last_entry_id": 6060625
  },
  "feeds":
  [
    {
      "created_at": "2014-02-26T12:42:49-05:00",
      "entry_id": 6060624,
      "field1": "188"
    },
    {
      "created_at": "2014-02-26T12:43:04-05:00",
      "entry_id": 6060625,
      "field1": "164"
    }
  ]
}

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

XML

To view a channel field feed, send an HTTP GET to https://api.thingspeak.com/channels/CHANNEL_ID/fields/FIELD_ID.xml, replacing CHANNEL_ID with the ID of your channel and FIELD_ID with the ID of your field.

Example GET:

The response is an XML object of the channel field feed, for example:

<?xml version="1.0" encoding="UTF-8"?>
<channel>
  <id type="integer">9</id>
  <name>my_house</name>
  <description>Netduino Plus connected to sensors around the house</description>
  <latitude type="decimal">40.44</latitude>
  <longitude type="decimal">-79.996</longitude>
  <field1>Light</field1>
  <field2>Outside Temperature</field2>
  <created-at type="dateTime">2010-12-13T20:20:06-05:00</created-at>
  <updated-at type="dateTime">2014-02-26T12:49:19-05:00</updated-at>
  <last-entry-id type="integer">6060650</last-entry-id>
  <feeds type="array">
    <feed>
      <created-at type="dateTime">2014-02-26T12:49:04-05:00</created-at>
      <entry-id type="integer">6060649</entry-id>
      <field1>160</field1>
      <id type="integer" nil="true"/>
    </feed>
    <feed>
      <created-at type="dateTime">2014-02-26T12:49:19-05:00</created-at>
      <entry-id type="integer">6060650</entry-id>
      <field1>171</field1>
      <id type="integer" nil="true"/>
    </feed>
  </feeds>
</channel>

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

Get Last Entry in a Field Feed

To get the last entry in a channel field feed, send an HTTP GET, replacing CHANNEL_ID with the ID of your channel and FIELD_ID with the ID of your field.

Valid parameters:

  • api_key (string) Read API key for this specific channel (optional--no key required for public channels)

  • timezone (string) Identifier from Time Zones Reference for this request (optional)

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

  • status (true/false) Include status updates in feed by setting "status=true" (optional)

  • location (true/false) Include latitude, longitude, and elevation in feed by setting "location=true" (optional)

  • callback (string) Function name to be used for JSONP cross-domain requests (optional)

  • prepend (string) Text to add before the API response (optional)

  • append (string) Text to add after the API response (optional)

Text

To get the last entry in a channel field feed, send an HTTP GET to https://api.thingspeak.com/channels/CHANNEL_ID/fields/FIELD_ID/last.txt, replacing CHANNEL_ID with the ID of your channel and FIELD_ID with the ID of your field.

For example, get the last temperature from the ThingSpeak™ weather station:

The response is the most recent value of the channel field:

31.8

JSON

To get the last entry in a channel field feed, send an HTTP GET to https://api.thingspeak.com/channels/CHANNEL_ID/fields/FIELD_ID/last.json, replacing CHANNEL_ID with the ID of your channel and FIELD_ID with the ID of your field.

For example, get the last temperature from the ThingSpeak weather station as a JSON object:

The response is a JSON object of the most recent feed:

{
  "created_at":"2016-02-10T16:34:15Z",
  "entry_id":877778,
  "field4":"31.8"
}

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

XML

To get the last entry in a channel field feed, send an HTTP GET to https://api.thingspeak.com/channels/CHANNEL_ID/fields/FIELD_ID/last.xml, replacing CHANNEL_ID with the ID of your channel and FIELD_ID with the ID of your field.

For example, get the last temperature from the ThingSpeak weather station as an XML object:

The response is an XML object of the most recent feed:

<?xml version="1.0" encoding="UTF-8"?>
<feed>
  <created-at type="dateTime">2016-02-10T16:37:16Z</created-at>
  <entry-id type="integer">877781</entry-id>
  <field4>32.3</field4>
  <id type="integer" nil="true"/>
</feed>

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

Get Age of Last Entry in Field Feed

Text

To get the age of the most recent entry in a channel field feed, send an HTTP GET to https://api.thingspeak.com/channels/CHANNEL_ID/fields/FIELD_ID/last_data_age.txt, replacing CHANNEL_ID with the ID of your channel, and FIELD_ID with the ID of your field.

For example, to get the age of the last temperature reading of the ThingSpeak weather station:

The response is the age of the most recent value of the channel field in seconds:

174

JSON

To get the age of the last entry in a channel field feed as a JSON object, send an HTTP GET to https://api.thingspeak.com/channels/CHANNEL_ID/fields/FIELD_ID/last_data_age.json, replacing CHANNEL_ID with the ID of your channel and FIELD_ID with the ID of your field.

For example, to get the age of the last temperature reading of the ThingSpeak weather station:

The response is a JSON object with the age of the most recent data, in seconds:

{
    "last_data_age": "174",
    "last_data_age_units": "s"
}

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

XML

To get the age of the most recent entry in a channel field feed in XML, send an HTTP GET to https://api.thingspeak.com/channels/CHANNEL_ID/fields/FIELD_ID/last_data_age.xml, replacing CHANNEL_ID with the ID of your channel and FIELD_ID with the ID of your field.

For example, to get the age of the last temperature reading of the ThingSpeak weather station:

The response is an XML object with the age of the most recent feed, in seconds:

<?xml version="1.0"?>
<feed>
  <last_data_age type="integer">174</last_data_age>
  <last_data_age_units type="string">s</last_data_age_units>
</feed>

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

Was this topic helpful?