API and Web API

What is an API?

An API (Application Programming Interface) is a structured set of rules, protocols, and tools that allow different software applications to communicate and share functionality. APIs are not limited to web-based interactions; they also exist in various forms, including Operating System APIs (allowing applications to interact with system resources like file systems or memory), Database APIs (facilitating querying and data manipulation in databases), Hardware APIs (enabling communication with devices like cameras or sensors), and Library APIs (offering predefined functionalities for developers to integrate into their applications). Some APIs operate locally within a system, some connect disparate systems, sometimes over a network.

What is a Web API?

A Web API is a specialized type of API designed for communication over the Internet using web protocols like HTTP/HTTPS. It facilitates interaction between clients and servers, enabling applications to request and exchange data dynamically. For instance, Web APIs power functionalities like embedding Google Maps into a website, fetching real-time weather updates, or processing online payments through gateways. By enabling seamless integration between platforms, devices, and services, Web APIs are crucial for building modern, interactive web applications.

Explain Arduino as API and Web API Client

Arduino as an API

Arduino can be understood as an API for hardware. Through its built-in Serial library, Arduino enables developers to send and receive data between the microcontroller and connected devices. For example, using functions like Serial.print() or Serial.read(), developers can transfer sensor readings to a computer or receive commands to control an actuator.

Arduino as a Web API Client

When equipped with network capabilities, such as Wi-Fi or Ethernet shields, or by using boards like the ESP32 or Arduino Uno WiFi, Arduino can interact with web servers via HTTP, making it capable of working with web APIs. This transforms Arduino into a powerful tool for Internet of Things (IoT) projects. For instance, an Arduino board can use a REST API to send sensor data—such as temperature or humidity readings—to a cloud server, which can then process and display the data in real-time on a dashboard. Similarly, it can retrieve data or control commands from a web server, such as fetching weather updates or toggling a connected device based on user inputs from a web application.

To distinguish:

P5.js as a Web API

P5.js as a commonly used tool in ITP as well as the creative field, is not just a creative coding library; it functions as a web API designed to make graphics, multimedia, and interaction accessible to everyone.

It operates on two primary levels: as a simplified JavaScript API and as an API for the HTML5 Canvas.

P5.js as a Simplified JavaScript API

p5.js simplifies the complexities of JavaScript by providing a high-level interface tailored for creative coding. For instance, functions like createCanvas() and mousePressed() make it easy to set up drawing environments and handle user interaction without requiring extensive knowledge of the Document Object Model (DOM) (give a link here) or event handling.

On top of that, p5.js extends JavaScript’s capabilities by incorporating features for animation, sound, video handling, etc.

P5.js as an API for the HTML5 Canvas