API Of The Week: Dweet.io

Guest author Kurt Collins is a developer evangelist for Built.io.

With Salesforce taking over the streets of San Francisco for its massive Dreamforce conference this week, it’s hard to remember that 15 years ago, Salesforce was just another startup scrapping for attention at tech conferences. At the Demo conference in February 2000, Salesforce demonstrated what was then a novel feature: a public Web API, or application programming interface.

On the strength of that open accessibility, Salesforce attracted other developers and customers who wanted to build software, not just buy it. It changed the world: Now it seems strange when a company doesn’t offer a public API.

The number of APIs has exploded. ProgrammableWeb is currently tracking almost 14,000 public APIs and sites like OneStack are making it easier to figure out which technologies integrate together. 

Welcome Back To API Of The Week

With all of these APIs out there, it’s time to restart an old ReadWrite tradition: the API of the Week. Where to start? Years ago, as this site explored the growing boundaries of the two-way Web, ReadWrite covered APIs from companies like UserVoice and Quora. Now machine-to-machine communication is hot—so it’s a good time to look at Dweet.io’s API.

In Twitter’s early days, people explored the idea of using it for machine-to-machine communications. But as its focus became a real-time media business, it’s proven less and less suitable for that purpose, with rules and guidelines that actively discourage automation.

See also: My Fish Just Sent Me A Text Message

Dweet.io addresses that gap in the market. Its stated purpose is to make it easy for your devices to communicate; what they communicate is up to you. Instead of sending tweets, each device (referred to as “things”) sends “dweets” to the cloud. Your dweet is public and it can contain any information you want by either passing a key/value pair in the query string or sending valid JSON data in the request body.

There’s no need to create a “thing” in the system before dweeting from it; the API will automatically register a thing the first time it dweets. 

In the following example, we will send a dweet from a thing named “builtio_dweets”. The content of the dweet will be four variables: hello, readwrite, builtio_lat, and builtio_long. You can create this dweet by calling the API hook: https://dweet.io/dweet/for/builtio_dweets?hello=world&readwrite=isawesome&builtio_lat=37.7844062&builtio_long=–122.4079684 

Every dweet automatically gets a timestamp attached to it. Every time you dweet, Dweet.io returns a simple response:

{     “this” : “succeeded”,     “by” : “dweeting”,     “the” : “dweet”,     “with” : {           “thing” : “builtio_dweets”,           “created” : “2015-09-08T22:30:24.712Z”,           “content” : {                 “hello” : “world”,                 “readwrite” : “isawesome”,                 “builtio_lat” : 37.7844062,                 “builtio_long” : -122.4079684            }     }}

In order to get the most recent dweet from builtio_dweets programmatically, all you have to do is make a simple call to this URL: https://dweet.io/get/latest/dweet/for/builtio_dweets

If you want a more visual representation of the most recent dweet, Dweet.io has set up a Web page for you to follow any public thing. What’s more, if there’s a lat/long pair in your dweet indicating its location, then the follow page will automatically update with a map.

Why Dweets Are Neat

You can also subscribe to dweets for your things. And finally, you can lock your things (thus reserving the name and making its dweets private), and also can set up email alerts so that Dweet.io can watch for any condition in the data and notify you of changes and status failures.

Every public thing is free. However, Dweet.io makes money by charging 99 cents to lock a thing. You can only set an alert on a locked thing. Dweet.io is the status update for your IoT devices. It’s a dead simple publish-subscribe API that allows you to get status updates running on the IoT device you’re building in your garage.

The incredible thing about Dweet.io is the simplicity. It’s simple to register a new thing to the network. It’s simple to have a thing report any data via query string parameters or JSON in the request body of an API call. You can get the 500 most recent dweets in the last 24-hour time period by making a simple API call. It’s clear that Dweet.io put a lot of thought into how developers use its API. Well done!

What do you think? Would you use Dweet.io? Tell us the things you’d like to have dweet, and why, in the comments.

Photo by JD Hancock

Editor’s note: While Built.io is currently a sponsor of ReadWrite’s Code section, Collins submitted this post independently through ReadWrite’s established guest-post program. Editorial is separate from advertising.

Facebook Comments