cover-img

Introduction to API

Discover APIs in Just 2 Minutes with an Exciting Example

26 August, 2023

0

0

0

What is API?

API stands for Application Programming Interface. It helps code to talk with other code. Nowadays APIs are the basic building blocks of modern software.

API allows various services, resources, and data across organizations, applications, and devices.


How do APIs work?

API architecture is usually explained in terms of client and server. The application sending the request is called the client, and the application sending the response is called the server. 


instructor_26fp2261340y1ukokimvca8su_public_1647355689_digitalrestaurant.1647355689760.pngImagine Raj goes to a restaurant and tells the waiter he wants to order Samosas. The waiter takes Raj's request and goes to the kitchen to fetch the Samosas. Once the Samosas are ready, the waiter brings them back to Raj.

In this scenario:

  • Raj represents a client, like someone using a website or a mobile app, who is making requests to get something.
  • The waiter represents an API, which is like a service that can take requests from clients and provide them with what they asked for.
  • The kitchen is like a server, which is where all the necessary stuff is kept.
Now, let's talk about an "Endpoint":
When Raj goes to the restaurant, he looks at the menu to decide what he wants. The menu is like an API's collection of services. Each dish listed on the menu is like an "endpoint" in the API. So, if Raj chooses to order Samosas, he's actually selecting an "endpoint" that corresponds to the Samosas dish. An endpoint is a specific part of the API that does a particular thing, just like how each dish on the menu does something different.
So, in the context of an API, an endpoint is like a specific item on the menu that you can order, and it represents a particular function or piece of information that you can request or interact with.


Why to use API?

  • API is fast & scalable.
  • Using API reduces the time of building own API.
  • It provides various features.
  • API can be public(for all), private(organisations) and partner(b/w partner organisations)


Types of API

  • Hardware API - Hardware API establishes the communication between hardware and OS / Software. Example: camera with software.
  • Software Library API - Software APIs are the libraries we use in our programming. Example: setTimeout() API provided by the browser.
  • Web API - Web API is over a network. Using Web API, anyone can fetch real-time data. Example: Weather API.


Architectures

  • REST (Representational State Transfer)
  • GraphQL
  • WebSockets
  • webhooks
  • SOAP (Simple Object Access Protocol)
  • gRPC (Google Remote Procedure Call)
  • MQTT (MQ Telemetry Transport)


REST API

REST API architectures are the most popular and widely used in applications. REST stands for Representational State Transfer. When a client request is made via a RESTful API, it transfers a representation of the state of the resource to the requester or endpoint. This information, or representation, is delivered in one of several formats via HTTP: JSON (Javascript Object Notation), HTML, XLT, Python, PHP, or plain text. JSON is the most generally popular file format to use because, despite its name, it’s language-agnostic, as well as readable by both humans and machines. 

Something else to keep in mind: Headers and parameters are also important in the HTTP methods of a RESTful API HTTP request, as they contain important identifier information as to the request's metadata, authorization, uniform resource identifier (URI), caching, cookies, and more. There are request headers and response headers, each with its own HTTP connection information and status codes.

About HTTP methods
In HTTP methods, 'headers' and 'parameters' play crucial roles. They provide essential details about the request, such as metadata, authorization, and more. There are 'request headers' and 'response headers,' each carrying its own information and status codes.


curl vs. Postman

Before Postman, the common way of using was command line tool (Terminal) for making HTTP requests using the curl command. It's used still today but has a lot of limitations.

continue-2.png

Whereas Postman is a user-friendly tool that shows a response, status, and response time, clean with colored text. It has the features of saving responses and organizing requests.

instructor_26fp2261340y1ukokimvca8su_public_1651760511_edit-apiresponse.1651760511674.png

Conclusion

APIs connect software, like friends sharing info. REST is common. Postman simplifies.

Follow for deeper tech insights! 😎

software

api

web

developer

webdeveloper

development

0

0

0

software

api

web

developer

webdeveloper

development

Vaibhav Maurya
Passionate Web Developer 🌟 #opensource πŸš€ | Tech #blogging @hashnode πŸ“ | Member @layer5 & @GrowInComm🌱 | Crafting digital dreams meticulously. πŸŒŒπŸ‘©β€πŸ’»

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

Β© Copyright 2024. Showcase Creators Inc. All rights reserved.