Hello folks! I recently started my Python journey and came across APIs while working on a simple project. So, I thought of sharing my learning regarding APIs in today's article.
What are APIs?
API stands for Applications Programming Interface. Well that doesn't convey something significant right? Basically, APIs are intermediaries that facilitate communication between different software applications, by abstracting out the complexities of direct communication. Hence making it easier for developers to interact with different systems.
What if we didn't had APIs?
Without APIs we (developers) would have to build custom communication systems for every interaction, which would be time-consuming and error-prone. APIs simplify the communication process between different software applications by abstracting away the underlying complexities.
We use APIs because :
they are efficient : they save time and effort by providing pre-build functionalities
they offer integration : they allow different applications to work together seamlessly
they add scalability : they can handle increasing loads and demands
An example of API
Google OAuth API is the most common API that we use in our everyday life. It is a pre-build solution that streamlines the login process for our application. It handles complexities of authentication, authorization and user data access, allowing us to focus on building the core feature of our application. By integrating Google OAuth, we can provide a seamless user experience and leverage the security and reliability of Google's infrastructure.
In short, Google OAuth will handle the login part of our application, which would have taken lot of time and effort if we built a custom login for our application.
What building a custom login would involve?
Building a custom login for our software application would involve the following steps/features :
designing a user-friendly login page with fields like username, email address, password etc.
implementing frontend validation to ensure that user enters valid data. Example : validating email format, calculating password strength and suggesting user to make for a stronger password in case the password isn't strong enough etc.
building backend authentication which would involve writing the server side logic that will handle user login request by verifying credentials against the database, and generate authentication tokens
implementing password hashing algorithms so as to keep those passwords safe
handling new user registration by creating a process for collecting and storing user information
implementing session management to keep track of the logged-in users and prevent unauthorized access
implementing a forgot password functionality that will provide a way for users to reset their password in case they forget it
addressing security vulnerabilities like SQL injections by regularly updating your code
So, now we know why using some good API (like Google OAuth API) to handle the login part of our software application would be better than building a custom login for our application.
Hope you found this article on APIs helpful. Happy coding😄!