0% found this document useful (0 votes)
52 views5 pages

API

Uploaded by

zehrasaba22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views5 pages

API

Uploaded by

zehrasaba22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

In the context of IoT (Internet of Things), APIs (Application

Programming Interfaces) act as a bridge that enables


communication between different IoT devices, applications, and
cloud services. They provide a standardized way for devices to share
data and interact with other systems, such as mobile apps, cloud
platforms, or even other IoT devices.

Here’s a simplified explanation of how APIs function in IoT:


What Do APIs Do in IoT?
Enable Communication: APIs allow IoT devices to communicate with
each other or with external systems. For example, a smart home
device like a thermostat can send data to your mobile app via an
API.
Data Sharing: APIs are used to send data collected from IoT devices
(like temperature readings from a smart thermostat) to cloud
platforms where the data can be processed, analyzed, or displayed
on user interfaces (such as a smartphone app).
Control IoT Devices: APIs also enable remote control of IoT devices.
For example, you can turn off your smart lights from your phone,
and this action is done through an API that sends the command to
the lights.
• In IoT (Internet of Things), two popular ways devices communicate with servers or other systems are
through REST APIs and WebSocket APIs. Let’s break down both in simple terms and how they work in IoT:
• REST API in IoT
• REST API (Representational State Transfer) is a way for IoT devices to communicate with servers using
simple, standard requests over the internet. It's like sending a message and waiting for a response.
• How REST API Works:
• Request and Response: An IoT device sends a request (like asking for data or sending data) to a server, and
the server responds with the requested data or a confirmation.
• Stateless: Each request made by the device is independent, meaning the server does not remember the
previous request.
• Example:
• Imagine you have a smart thermostat:
• The thermostat measures the temperature in your home.
• It sends the temperature data to a cloud server using a REST API.
• The cloud server stores the data and sends back a confirmation response (like "Data received
successfully").
• You open a mobile app to check the temperature. The app makes a REST API call to the cloud, which sends
back the current temperature.
• Key Features of REST API:
• Simple: Uses HTTP methods (like GET, POST, PUT, DELETE) to communicate.
• Good for periodic updates: If your IoT device only needs to send or receive data every few minutes or
hours, REST is a good choice.
• REST API Use Cases in IoT:
• Smart Home Devices: Sending status updates like temperature, light levels, or security alerts.
• Remote Monitoring: Devices in agriculture or industrial IoT sending periodic updates to the cloud.
• WebSocket API in IoT
• WebSocket API is a way for IoT devices and servers to maintain a constant, two-way connection. This allows
real-time communication between them, meaning the device can send and receive updates immediately.

• How WebSocket API Works:


• Persistent Connection: Unlike REST, where the connection is opened and closed for each request, WebSockets
keep the connection open, allowing real-time data exchange.
• Two-Way Communication: Both the device and server can send messages to each other whenever they want,
without waiting for a request.
• Example:
• Imagine you have a smart security camera:
• The camera is connected to the cloud using a WebSocket API.
• When the camera detects motion, it immediately sends a video feed to the server through the open
WebSocket connection.
• The server processes the data and can send commands (like turning on a light or triggering an alarm) back to
the camera in real-time.
• You, as a user, can watch the live video feed on your phone instantly, without delays.

• Key Features of WebSocket API:


• Real-Time: Great for applications that need immediate data, like live video, sensor alerts, or controlling devices
instantly.
• Efficient: Since the connection stays open, there's less overhead compared to REST, which opens and closes
the connection for each request.
• WebSocket API Use Cases in IoT:
• Smart Security Systems: Real-time video feeds, instant motion detection alerts.
• Remote Control: Controlling devices like drones, robots, or industrial machines in real-time.
• Live Monitoring: IoT systems that need continuous updates, like heart rate monitors, air quality sensors, or
smart grids.
Feature REST API WebSocket API
Short-lived Persistent (always
(request-response) open)

Periodic data Real-time data


updates (e.g., (e.g., live video,
smart thermostat) alerts)

One-way per Two-way, instant


request (device (device and server
requests data) both send data)

More overhead Less overhead


(new connection (single open
each time) connection)

Data sent at Real-time updates


intervals, lower and immediate
urgency control
• What is IoT? (Internet of Things)
• The Internet of Things (IoT) is about connecting physical devices to the internet so they can send and receive data. These devices
include things like smart thermostats, sensors, cameras, and even household appliances like refrigerators or light bulbs.
• Key Points about IoT:
• Devices: Physical objects (sensors, machines, appliances) that are connected to the internet.
• Goal: To collect data, send it to the cloud, and sometimes allow remote control of devices.
• Communication: IoT devices often use specific protocols (like MQTT, CoAP) to communicate with the cloud or other devices.
• Example:
• A smart thermostat that measures the temperature in your home and sends the data to a cloud server so you can control it via an
app.
• What is WoT? (Web of Things)
• The Web of Things (WoT) builds on top of the IoT, but it focuses on making IoT devices accessible and interactable
through web technologies (like websites, HTTP, and REST APIs). WoT aims to standardize how IoT devices are
controlled and how they share data by using the web.
• Key Points about WoT:
• Web Technologies: Uses familiar web standards (like HTTP, WebSockets, REST APIs) to access IoT devices.
• Goal: To make IoT devices easier to interact with, especially for developers, by using web technologies to create
uniform access.
• Interoperability: WoT provides a way for different IoT devices from different manufacturers to work together
seamlessly through the web.
• Example:
• You can control your smart thermostat, lights, and security camera through a single web interface or mobile app,
even if they come from different brands, because WoT enables them to speak the same "web language."

• Think of IoT as the hardware and connections, while WoT


is the user-friendly layer that makes interacting with
these devices simpler through the web.

You might also like