Vous êtes sur la page 1sur 8

5.

2 THINGSPEAK:
ThingSpeak is a free web service that lets you collect and store sensor data in the cloud
and develop Internet of Things applications. The ThingSpeak web service provides apps that let
you analyze and visualize your data in MATLAB, and then act on the data. Sensor data can be
sent to ThingSpeak from Arduino, Raspberry Pi, Beagle Bone Black, and other hardware.

5.2.1 KEYWORDS:
Here are some keywords that are used in the API. An understanding of the terms will
make the API documentation easier to understand.

 Channel – The name for where data can be inserted or retrieved within
ThingSpeak API, identified by a numerical Channel ID
 Field – One of eight specific locations for data inside of a channel, identified by a
number between 1 to 8 – A field can store numeric data from sensors or
alphanumeric strings from serial devices or RFID readers
 Status – A short status message to augment the data stored in a channel
 Location – The latitude, longitude, and elevation of where data is being sent from
 Feed – The collective name for the data stored inside a channel, which may be
any combination of field data, status updates, and location info
 Write API Key – A 16 digit code that allows an application to write data to a
channel
 Read API Key – A 16 digit code that allows an application to read the data stored
in a channel

5.2.2 ADDRESSES AND LOCATION:


Regular URL: [cce]http://api.thingspeak.com[/cce]

Secure URL: [cce]https://api.thingspeak.com[/cce]

IP Address: [cce]https://184.106.153.149[/cce]

Cross-domain XML: [cce]https://api.thingspeak.com/crossdomain.xml[/cce]

5.2.3 WRITE API KEY:

In order to update a channel, you need to know your write API key. If your write API key
gets compromised you can generate a new key.

Follow these steps to get your write API Key:

 Select Channels
 Select the Channel to update
 Select Manage API keys

5.2.4 READ API KEY:


The Read API Key allows your applications to read data from the API. You can generate
multiple Read API Keys for different applications.

Follow these steps to get a Read API Key:

 Select Channels
 Select the Channel to update
 Select Manage API keys
 Select Generate New Read API keys

5.2.5 CHANNEL ID:


Every channel has a unique Channel ID. The channel ID number is used to identify the
channel when your application reads data from the channel.

5.2.6 PRIVATE/PUBLIC CHANNELS:


By default, your channel is private and requires a Read API keys to access its feed. You
can make a channel public which gives other users the ability to use your feed without a Read
API Keys.

5.2.7 API RATE LIMIT:


The open service via Thingspeck.com has a rate limit of an update per channel every 15
seconds. This limit is so that the service can remain free and given everyone a high-level of
service. The API source will also be made available on GitHub so that you can run this locally or
via a shared web host provider. At that point you will be able to tweak settings for your
application requirements.

5.2.8 CACHING:
Caching is implemented on JSON and XML formats on feeds. Feeds that return more
than 100 entries are cached for 5 minutes. This will allow great performance for popular that you
can produce real-time applications. The last API call and feeds that specify “results=100” or less
are not cached, so that can produce real-time applications.

5.2.9 UPDATING A CHANNEL:


Method: POST or GET
Update URL: [cce]https://api.thingspeak.com/upadate[/cce]

Required Parameter:

 Key=[write API Key]

Optional Field Parameters:

 field1=[Field 1 Data]
 field2=[Field 2 Data]
 field3=[Field 3 Data]
 field4=[Field 4 Data]
 field5=[Field 5 Data]
 field6=[Field 6 Data]
 field7=[Field 7 Data]
 field8=[Field 8 Data]

Optional Location Parameters:

 lat=[Latitude in decimal degrees]


 long=[Longitude in decimal degrees]
 elevation=[Elevation in meters]

Optional Status Parameters:

 status=[Status Update]

Optional Twitter Parametesr:

 twitter=[twitter Username linked to ThingTweet]


 tweet=[Twitter Status Update]

Reply: If the update is successful, the API will respond with the entry_id of the update. If the
response is “0” then the update failed.

5.2.10 RETRIEVING:
1. Retrieving Channel Feeds:

Method: GET

Feed URL:

[cce]https://api.thingspeak.com.channels/(channel_id)/feed.(format)[/cce]
Optional Parameters:

 Key=[Read API Key] –no key required for public channels


 Results=[number of entries to retrieve (8000 max)]
 days=[days from now to include in feed]
 start=[start date] - YYYY-MM-DD%20HH:NN:SS
 end=[end date] – YYYY-MM-DD%20HH:NN:SS
 offset=[timezone offset in hours]
 status=true (include status updates in feed)
 location=true (include latitude, longitude and elevation in feed)
 min=[minimum value to include in response]
 max=[maximum value to include in response]
 round=x (round to x decimal places)
 timescale=x (get first value in x minutes, valid values: 10,15,20,30,60,240,720,1440)
 sum=x ( get sum of x minutes, valid values:10,15,20,30,60,240,720,1440)
 average=x (get average of x minutes, valid values: 10,15,20,30,60,240,720,1440)
 median=x (get median of x minutes, valid values: 10,15,20,30,60,240,720,1440)
 callback=[function name] (used for JSONP cross-domain requests)

Examples:

 http://api.thingspeak.com/channels/9/feed.json
 http://api.thingspeak.com/channels/9/feed.json?median=10
 http://api.thingspeak.com/channels/9/feed.json?start=2011-11-
11%2010:10:10&end=2011-11-11%2011:11:11

2. Retrieving the last Entry in Channel Feed

Method: GET

Feed URL:

[cce]http://api.thingspeak.com/channels/(channel_id)/feed/last.(format)[/cce]

Optional Parameters:

 key=[Read API Key]


 offset=[timezone offset in hours]
 status=true (include status updates in feed)
 location=true (include latitude, longitude, and elevation in feed)]
 callback=[function name] (used for JSONP cross-domain requests)
3. Retrieving a Field Feed

Method: GET

Feed URL:

[cce]http://api.thingspeak.com/channels/(channel_id)/feed/(field_id).(format)[/cce]

Optional Parameters:

 key=[Read API Key]


 results=[number of entries to retrieve(8000 max)]
 days=[days to include in feed]
 start=[start date] – YYYY -MM-DD%20HH:NN:SS
 end=[end date] – YYYY -MM-DD%20HH:NN:SS
 offset=[timezone offset in hours]
 status=true (include status updates in feed)
 location=true (include latitude, longitude, and elevation in feed)
 min=[minimum value to include in response]
 max=[maximum value to include in response]
 round=x (round to x decimal places)
 timescale=x (get first value in x minutes, valid values: 10,15,20,30,60,240,720,1440)
 sum=x (get sum of x minutes, valid values: 10,15,20,30,60,240,720,1440)
 average=x (get average of x minutes, valid values:10,15,20,30,240,720,1440)
 median=x (get median of x minutes, valid values:10,15,20,30,60,240,720,1440)
 callback=[function name] (used for JSONP cross-domain requests)

4. Retrieving the Last Entry in a Field Feed

Method: GET

Feed URL:

[cce]http://api.thingspeak.com/channels/(channel_id)/feed/(field_id).(format)[/cce]

Optional Parameters:

 key=[Read API Key]


 offset=[timezone offset in hours]
 status=true (include status updates in feed)
 location=true (include latitude, longitude, and elevation in feed)
 callback=[function name] (used for JSONP cross-domain requests)
Optional Format:

 txt

Optional Parameters for TXT format:

 prepend=[text to add before the API response]


 append=[text to add after the API response]

5. Retrieving Status Updates

Method: GET

Feed URL:

[cce]http://api.thingspeak.com/channels/(channel_id)/status.(format)[/cce]

Optional Parameters:

 key=[Read API Key]


 offset=[timezone offset in hours]
 callback=[function name] (used for JSONP cross-domain requests)

5.2.11 LISITING:
1. Listing Public Channels:

Method: GET

Public Channels URL:

[cce]http://api.thingspeak.com/channels/public.(format)[/cce]

Optional Parameters:

 page=[page number to retrieve]


 tag=[name of tag to search for, should be URL encoded]

Examples:

 http://api.thingspeak.com/channels/public.json
 http://api.thingspeak.com/channels/public.xml
 http://api.thingspeak.com/channels/public.json?page=5
 http://api.thingspeak.com/channels/public.json?tag=temperature
2. Listing User Information

Method: GET

User Information URL:

[cce]http://api.thingspeak.com/users/(username).(format)[/cce]

Optional Parameters:

 key=[Read API Key]

If a user’s API key is provided, private information such as their email address will be provided.

Examples:

 http://api.thingspeak.com/users/hans.json

3. Listing a User’s Channels

Method: GET

Users Channels URL:

[cce]http://api.thingspeak.com/users/(username)/channels.(format)[/cce]

Optional Parameters:

 Key=[user API Key]


 If a user’s API Key is provided, private channels will also be displayed.

Examples:

 http://api.thingspeak.com/users/hans/channels.json

Vous aimerez peut-être aussi