🔹What is an API?

In this thread, I'll tell you all you need to know about Application programming interfaces (APIs).

P/S: If you find this thread helpful, kindly retweet 🙏

⬇️
🔹What is an API?

An API (Application programming interface) is simply the set of rules guiding how a client browser communicates with a web server to exchange data.

Three parties to note are:

- Browser (Client)
- Server (Back-end)
- A network (the Internet)
When we talk about APIs, we talk about requests and responses. A client makes a request to a server for data (HTML page or json data) over a network (The internet) and the server responds with the data.

The data transmitted to and fro are stored in something called Headers.
REST API: This lets you put and pull data from a database.

Four actions in REST APIs includes:

GET: This method retrieves data from a database

POST: This method inserts data into a database

PUT: This method updates an already existing data.

DELETE: This method deletes data
The browser and server, both possess APIs for initiating and maintaining communication with each other. For the browser, we have the built-in fetch API.

This snippet displays how a browser makes an Xhr request with it:

N/B: The parameter passed to fetch must be url to the data
For the server, which can be typically set up with any server side framework, such as Express.js in JavaScript, this how the typical API looks like:
IN SUMMARY

The web browser (client) makes a request and a web server responds with data, or an error message with status codes.

The data is transmitted in two popular forms, JSON and XML.

JSON is the most widely used. So, to be able to transmit data, you must parse it to JSON
I have a cleansheet on all the API request/response properties and methods, middlewares and handler functions used by the Express API: https://mobile.twitter.com/UbahTheBuilder/status/1354438790547439621
Do well to follow me @UbahTheBuilder for similar tweets on web development.

You can also ask me any questions.📨
You can follow @UbahTheBuilder.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.