Bummer! This is just a preview. You need to be signed in with a Pro account to view the entire video.
Future of the Internet - APIs of Everything15:35 with Boken Lin
APIs are ubiquitous in the software world. They are one of the fundamental building blocks of the Internet that allows different services to communicate with each other to create intelligent automation systems that make the Web so convenient. With the recent development of the Internet of Things, APIs are no longer limited to the software world. Slowly, more and more hardware products have APIs that allow them to interact with software as well as other hardware devices. This is significant; for the last 15 years the Information Technology industry has been digitizing the world around us (i.e. capturing and storing sensor data from the environment).Now, using APIs, we can feed this information back into the real world, providing devices around us with the information to make intelligent and informed decisions. This is the dawn of machine intelligence and true automation. This session will walk through the three step-process of creating APIs for the real world: 1) attaching API end points to hardware devices; 2) connecting APIs together; and 3) introducing intelligence to the system by setting up trigger events and response events.
This presentation is actually gonna be quite a bit shorter than I had 0:00 planned because I just landed in Boston this morning from Thailand and 0:04 apparently they lost my luggage. 0:09 And I was planning to show you guys a really cool demo of, 0:11 you know, what you can do with different things and all that. 0:14 But I guess that's not gonna happen. 0:18 So I apologize in advance for that. 0:20 So so yeah. 0:24 I'm Bokan and I am the cofounder of a Boston based company. 0:27 What we're working on is a cloud backend for connected devices. 0:32 So if you don't really know what that means, think of either parts or 0:37 kinbay, but for connected devices rather than mobile apps. 0:42 And so I spent a lot of time working with connected devices, and 0:47 trying to connect hardware and software. 0:52 And about a couple of years ago, I realized, oh, you know, 0:56 why, why can't we make a device smarter than they are. 1:02 I mean there are a lot of what we usually think of as dumb devices, 1:06 like tables and chairs. 1:12 But, by incorporating some kind of a computational or 1:14 some kind of a sensor into it, they can actually provide a lot of data. 1:21 For us and we'll be able to make use of, of those data 1:26 to make intelligent decisions and that's what IoT is re, really about. 1:29 So, I'm sure everyone here has heard of IoT. 1:35 What Internet of Things will this entire movement is, is really about two things. 1:39 The first is the slow transition of everything around us from 1:46 the way they are now into some form of computer. 1:52 As computer chips and memories and hard drives get cheaper and 1:58 cheaper and they can be manufactured to be smaller and smaller. 2:04 It becomes possible to, to embed in these what used to cost a lot and, 2:07 and very large in size into products that we see every day. 2:13 And that's what allow different things to be smarter, 2:19 to be able to make smarter decisions what they, what they used to be able to do. 2:25 And the second thing that really drove IoT is that we are, 2:31 we are trying to connect these specialized computers onto the web. 2:36 So, these smart devices are slowly starting to show features 2:41 that we typically associate with software applications. 2:49 For example, they'll be able to get huge amounts of data from the web and 2:53 they'll be able to make intelligent decisions based on these data. 2:58 And. 3:03 So the, the IoT movement is really is really 3:04 blurring the boundaries between the physical world and the software world. 3:09 So as many of these hardware devices are becoming connected and becoming smart. 3:16 I would like, I, I generally think of them as hardware apps because they 3:25 are generally very specialized in doing one thing, and that's typically how 3:29 an app is, is made whether it's for your phone or it, it, or it's for the computer. 3:36 So the way that so I, 3:43 I'm not sure how familiar you guys are with how connected devices are made, 3:48 but they're typically made with small computers, or micro-controllers, 3:54 that are very good at at interacting with the real world. 4:01 And as these devices get cheaper and cheaper more and 4:08 more companies are starting to incorporate them into their products and 4:13 that's why we see a lot of smart devices that are emerging in the marketplace. 4:18 So creating APIs for 4:26 these hardware apps are not that different from creating APIs for a software app 4:29 because they're essentially both software that run on some type of computer. 4:36 And what an API really does is it, it exposes some of the functionality within 4:41 these computers so that third party applications can interact 4:46 with them without needing to understand exactly how they work internally. 4:51 That's what essentially an API is. 4:56 But because a hardware app and the app that we, that we generally think about 4:59 are both essentially software running in some type of a computational device. 5:07 The, the way we think about them shouldn't be all that all that different. 5:14 So there are typically two ways that hardware APIs are made. 5:22 About five years ago, 5:30 people tried very hard to run all the service on the device itself. 5:32 And they run into a lot of problems. 5:40 For example, these embedded devices are usually not very powerful, so 5:42 if you hit it with a lot of traffic, and these devices will generally fail. 5:47 And because most of these embedded devices also have a very low power consumption, 5:53 if you if you try to host the, the API service on these devices. 5:59 Chances are they are going to malfunction. 6:09 So what, what many people are trying to do now is trying to is, 6:13 is trying to proxy these A, APIs with servers that are on the web. 6:20 So this is the, the model that's more popular now. 6:28 And this is the type of Cloud that we are trying to make. 6:34 So instead of hosting the API service directly on the device, 6:38 what we have is a Cloud service that actually has the API ser, service. 6:44 And we are creating some kind of a much simpler service that 6:50 allow a better device to communicate with the cloud. 6:53 And it, it would be the cloud that's actually exposed to all the API consumers. 6:57 And whenever a third party app calls the API, 7:04 the cloud will then be responsible to relay the information to the, 7:10 to the embedded device and trigger some form of action on there. 7:14 So how do we actually know a hardware based API? 7:21 There's actually just a three step process. 7:26 It, it's very simple. 7:29 I mean, if you consider how you build a regular API on software apps, 7:31 it's really about first defining a function and then trying to exploit this 7:36 function in such a way that it's easy for other applications to interact with it. 7:40 It's the same way here with the hardware APIs. 7:46 The first step would be to program the connected device. 7:50 So I used a very simple example here, which is just a lightbulb. 7:55 And you would write you write code within the device, 8:00 in this case just, you know, simple on and off functions. 8:06 And once you have defined these functions, what you will want to do is, 8:11 is to connect it to a cloud. 8:17 And connecting this and connecting these embedded device through cloud is, 8:23 is actually a very, is actually a very similar process to logging onto Facebook, 8:29 because each of these device essentially have their own profile on the web. 8:34 And by logging in, you also prevent 8:40 other device from trying to from trying to pretend to be that device. 8:47 And the cloud will be, also be able to check the, the, 8:55 the ID and the key of the device to make sure it is who it claims it, itself to be. 9:01 And once the device has successfully logged on, 9:09 we create a virtual device in so, think of it like. 9:14 Think of like how Unix abstracts every device or everything into a file. 9:22 If you want to interact with a device such as a printer, you would just write to it. 9:29 And, in the Internet of Things world, we, we try to take that one step further. 9:33 So ins, instead of trying to make everything into a file, 9:38 we try to make it into a URL. 9:40 So, whether it's a lightbulb or if it's a thermostat, 9:43 you can interact with it just by using get and post request. 9:46 And the third step, once the device has logged on, would be to to take the fu, 9:54 the fu, the functionality that you define in the first step and turn them into APIs. 10:02 So in this case, what we will be doing is we'll be mapping each 10:08 each of the function that's available on the device to a web as a endpoint, 10:14 like this. 10:22 And then these APIs will be accessible all over the world and will be very easy for 10:24 third party applications to interact with the physical device. 10:33 But technology that that are typically used by 10:39 by IoT companies now are just very simple. 10:44 JSON-RPC so you can, you can pass data into these functions. 10:49 You can get, you can also get data returned from these A, APIs. 10:55 So, how are these hardware APIs actually used. 11:02 I'm sure you guys have been paying, you know, some attention in the IoT field. 11:08 And, and, to be honest, I'm a little bit disappointed because most of 11:12 the applications out there are somehow turning a regular device into 11:17 something that you can remote control with your phone. 11:22 And I, I don't personally think they're very interesting, 11:25 because it's like going back to the 70s when remote control was first invented. 11:27 So there really isn't anything new to it. 11:31 So but with, with the exposed API, I think there can be a lot of possibilities. 11:34 For example, the, the one thing that we try to do a lot in our company is to 11:43 allow different devices to interact with each other. 11:47 So, for example, this is a project that we did for 11:51 a company in China and they're making lawn sprinklers that are connected to the web. 11:56 And they, they also make some soil sensors that will you know, 12:03 sense how moist the soil is. 12:09 And by connecting these two devices together, 12:12 we no longer need to manually turn on the sprink, the sprinkler. 12:15 We can ask the soil sensor to to call the API of the sprinkler whenever it, 12:21 it knows that the soil is, is too is too dry. 12:28 And, with these exposed APIs, we can also get devices to 12:35 automatically pull data from the Web and make intelligent decisions about them. 12:40 So with the same project we've also added functionalities that allow the sprinkler 12:46 to pull data from Yahoo whether network and a few other web APIs. 12:54 And only turn on when it, it knows for sure it's not going to rain. 13:01 Otherwise, it's just going to be wasting water. 13:07 So that's another potential. 13:10 And the third one is more of a corporate use. 13:14 It's how many people here actually fill out warranty cards? 13:17 Because I, I know I never do that. 13:23 And with IoT, what a lot of companies are, are trying to do is, 13:25 they don't get their customer to fill out warranty cards anymore, because they will, 13:30 they will know exactly when their products are being unboxed. 13:34 They know exactly what condition these devices are in, 13:38 and they'll know if a part within the device is going to break so 13:42 they can send you a coupon to get a new one or to replace it free for free. 13:47 So these are some of the things that we are going to start to see more and more in 13:52 the next, you know, five to ten years as people slowly shift out of the mindset of, 13:58 oh, if I can remote control my device with a phone, it's a smart device. 14:04 I, I think there's a lot more to a smart device than just being remote controlled. 14:09 So that's the demo that I was supposed to show you guys but, 14:16 it's on it's way here from Korea right now. 14:22 So that's probably not going to happen. 14:26 But it's supposed to be a you guys know Dropcam? 14:30 Yeah, so I've, it's actually made something like a Dropcam because I've. 14:36 It's better, because you can re, remote control it. 14:42 You can turn it by calling different web APIs. 14:45 And what I really wanted to do with the demo was to show you guys how easy it is 14:50 to to go from a really dumb device into something that has a little bit of in, 14:56 in, intelligence in it. 15:01 And another thing that I was planning to show with this was 15:04 I made a service online that listens to what people Tweet. 15:09 And the camera will, will, will react. 15:15 Depending on what people Tweet, but it's too bad that I won't be able to show that. 15:19 yeah, so like I said, it's gonna be a very short presentation, but. 15:27 You guys have any questions? 15:32
You need to sign up for Treehouse in order to download course files.Sign up