API In-Depth
- Application Programming Interface. more
- mechanisms that enable two software components to communicate with each other using a set of definitions and protocols.
- API takes
request
from client/App1 <--> Interact with Server1 & process theResponse
-> return to Client/App. - Real Life Case:
- Flight booking websites (uses API’s provided by airlines and hotel)
- Users can create an account through Google with just one tap. (Apps uses the Google API to verify the user’s identity)
- The weather app on your phone “interact” to this system via APIs and shows you daily weather updates on your phone.
- RPC2 (client completes a function on the server, and the server sends the output back to the client.)
- SOAP (Client and server exchange messages using XML)
- Websocket3 (JSON objects to pass data, supports two-way communication)
- REST (The server uses this client input/Data to start internal functions and returns output data back to the client)
- Representational State Transfer.
- Clients and servers exchange data using HTTP methods.
- REST API is
statelessness
. Statelessness means thatservers do not save client data between requests
- REST defines a set of functions like
GET, PUT, DELETE
etc. that clients can use to access server data. - The most-commonly-used HTTP methods are
POST, GET, PUT, and DELETE
more which correspond tocreate, read, update, and delete (or CRUD) operations.
- automatically update data between clients and servers.
- automatic data sync to the cloud from your phone image gallery.
- the time and date automatically sync on your laptop when you travel to another time zone.
- Authentication tokens, API keys.
Footnotes
-
The application sending the request is called the client, and the application sending the response is called the server. ↩ ↩2
-
This is a less flexible API that was more popular in the past. ↩
-
Websocket API is another modern web API development that uses JSON objects to pass data. A WebSocket API supports two-way communication between client apps and the server. ↩