This is a .NET Class library for ThingSpeak.
This library depends on Json.NET (http:https://james.newtonking.com/json).
You do not need ThingSpeak Account to try using this library. There are a lot of public channels that allow anonymous data retrieval. But if you want to create your own channel and send data to it, you'll need a ThingSpeak Account (https://thingspeak.com/).
You have to instantiate the Class with the constructor and provide a bool value if you want to make all communications with or without SSL. After that you are ready to get started.
var client = new ThingSpeakClient(sslRequired: true);
After you have created a Channel on the ThingSpeak Website you could add a new feed inside the channel with the following commands:´
var dataFeed = new ThingSpeakFeed { Field1 = "58.27", Field2 = "32.59" };
dataFeed = await client.UpdateFeedAsync("<Your Write API Key>", dataFeed);
If there occurs any error, the dataFeed.Id entry will be null. If everything works ok, the Id of the entry will be what Id is returned from ThingSpeak.
var feeds = await client.ReadAllFeedsAsync("<Your Read API Key>", <Your Channel Id>);
This command returns an item of the type "ThingSpeakData" which contains a Channel item and a Collection of all feed items which are in the channel.
var feed = await client.ReadFeedAsync("<Your Read API Key>", <Your Channel Id>, <Your Feed Id>);
This command returns the specified feed in the channel which is of the type "ThingSpeakFeed".
var feeds = await client.ReadLastFeedAsync("<Your Read API Key>", <Your Channel Id>);
This command returns the last feed in the channel which is of the type "ThingSpeakFeed".
var feeds = await client.ReadFieldsAsync("<Your Read API Key>", <Your Channel Id>, <The id of the field>);
This command returns an item of the type "ThingSpeakData" which contains a Channel item and a Collection of all feed items which are in the channel but only the specified field isn't null.
var feeds = await client.ReadLastFieldFeedAsync("<Your Read API Key>", <Your Channel Id>, <The id of the field>);
This command returns the last feed in the channel which is of the type "ThingSpeakFeed", where only the specified field isn't null.
var feeds = await client.ReadStatusUpdateAsync("<Your Read API Key>", <Your Channel Id>);
This command returns an item of the type "ThingSpeakData" which contains a Channel item and a Collection of all feed items which are in the channel but only the status isn't null if anything is there.
You need to first setup a ThingTweet Account and link it to your Twitter account.
var tweet = await client.SendThingTweetAsync("<Your ThingTweet API Key>", "Your Twitter Status");
This command returns a bool which is true when the command was successfully sent to the ThingTweet API. You should now see the Twitter Status Update.
You need to setup a ThingHTTP Account.
var tweet = await client.SendThingHttpAsync("<Your ThingHTTP API Key>", "Your Message");
This command returns a bool which is true when the command was successfully sent to the ThingHTTP API.
- If your channel is public you have to pass null instead of the Read API Key.
- If you want to further dive into the APIs check out the documentation here: https://thingspeak.com/docs