An Introduction to APIs: Types, Advantages, and Challenges
API is short for Application Programming Interface. It helps in making a developer workflow easy as it simplifies the backend work and gives developers what they need.
I call it A Perfect Invention.
Example: Imagine a Coffee machine with latte, black coffee as options. If you select latte then it gives you a latte i.e it uses all the ingredients needed to make a latte, makes it behind the screen, and gives the latte to user. So instead of you going through the entire latte making process now you just get it in a single button.
Different Types of API:
REST APIs : Representational State Transfer(REST) APIs are commonly used API for web services.
SOAP APIs: Simple Object Access Protocol(SOAP) APIs are type of web services that use XML messaging and are used for complex transactions
GraphQL APIs: These provide a way to easily access data. These allow developers to specify the exact data they need in a single request and can reduce the amount of data transferred over network
Open APIs: These are known as public API, are accessible to developers outside of the organisation that provides them. EXAMPLE: Weather API
Internal API: These are private APIs, used within the organization to share resources and data between different departments
How APIs Work?
The client application sends a request to the API, specifying what data is required
API then receives the request and process it and perform the requested action
API takes the data from the database and performs the requested action
API makes the data into JSON or XML and sends that as response back to the client application
The client application receives the response and whatever the user requested will be shown to the user
Examples of API
When we order food from Zomato(food delivery app) we see the map in the app. That map is not developed by the developers completely from scratch instead they request for the map using google maps API and build the time, and driver info on top of that.
Recently Twitter has commercialized its APIs. Tweet schedulers got affected because of that this is because they are built using the Twitter API.
Though people got worried that they might get banned users can create their own keys instead of system-generated keys and paste them in those schedulers.
Advantages of API
Hides all complexities
Extend functionalities without bothering backend logic
Reusability: Devs time gets saved as they don't need to build functionality from scratch
Scalability: Millions of users get data as per their request
Monetization of API: revenue stream is generated for providing data or functionality as devs use this to develop something using this API
Challenges with API
API security versioning and scalability
Security: APIs are constantly facing security issues in the form of data breaches, DOS attacks(Denial of Service), and injection attacks.
Performance: Poorly designed API leads to poor performance in the application and disturbs user experience
Maintenance: APIs must be maintained from time to time to make sure they work as expected and also keep them secure. Changes sometimes consume a lot of time and money
Overall API provides a standardized way for different software applications to communicate and share data, which is essential in today's interconnected world of software and services.
I request the reader to suggest any changes, share their knowledge regarding API and help me learn more about API. This is a part of my #100daysofCode so please share your knowledge and experience and further learning concepts in this API world.