While learning about IoT systems I have stumbled upon the word API, REST API and JSON many times. Although I kind of knew the meaning, now I took the time to learn in more details what exactly these mean so it crossed my mind why not write a brief article about it. Bear in mind that apart from some programming in Matlab for my PhD, I wouldn’t call myself a programmer 🙂
For that reason, I will briefly describe what these are and if you are programmer you can just skip this post. If however you would like to know what these acronyms actually mean and what they mean in IoT I believe my short explanation will come in handy.
First let’s define what’s an API?
API (short for Application Programming Interface) is actually a clearly defined user interface that software exposes to the world i.e. other programs can use the API by passing some strictly defined inputs. So the software providing API can be thought of like a black box, it can be accessed (inputs sent and outputs received via API) without knowing the internal structure of the box.
The very good metaphor is you driving the car. You don’t actually need to know how really the car works (motors, steereing, gears, tyres, electronics etc.) you just send input through your input interfaces (wheel, gear level and pedals) to perform any action you like.
Then the more tricky….REST part
A RESTful API is one way (there are others, like SOAP for instance) in which programs, servers, and web sites can share data and services. REST (Representational State Transfer) is just a pattern or more precisely a software architectural style for making APIs so that in the end, other programs can correctly request and receive data and services that an API makes available.
As with any architecture there are some rules and constraints that it must follow some being based upon resources and upon resource representation. There are of course more rules since REST is more complex so in case you really want to dig deeper there is a very good video here.
JSON stands for the Java Script Object Notation. It’s not a programming language like C or Python i.e. it’s actually a format of messages through which programming languages can exchange information.
The JSON format looks quite simple i.e. it looks like a Table of contents, but instead of page numbers, the information can be found directly under a section of the table.
Why knowing these is important for IoT?
Although IoT starts with sensors/actuators and uses several types of communication infrastructure, IMHO the most important part of any IoT solution is the IoT application together with IoT platform which it uses. Since it’s very important for these two to be widely usable and inter-operable APIs must be used. Also, since most of the time these are web applications hence HTTP and REST APIs are used.