Things You Need to Know About API Testing
Let's take a look at a video about API testing as well as explore what APIs are and how they work.
Join the DZone community and get the full member experience.Join For Free
This video is contributed by Supriya Baru
What Is an API?
If you already know, if you have googled it, or if you are a little confused about what it is, just focus on what we are talking about here in this article. An API is nothing but an application program interface.
How Does API Testing Work?
It is all about requests and responses between the client and server. You want something, you request for something, so there is a way it gets carried to the server and you get the response back from the server. In other words, it's all about your requesting and getting some responses from the provider.
Real World Examples
Example 1: Let's compare it with a real-world example: You go to a restaurant and sit at your table, and you choose what you want. You will have your waiter come up and take a note of what you want. So, you are requesting what you want, and the waiter responds back with what you want when he goes to the kitchen. Then, he serves you the food. In this case, who is your interface between you and the kitchen? It is your waiter. It's his responsibility to carry the request from you to the kitchen, make sure it gets done, and you know once it is ready because he gets back to you with a response.
Example 2: Another important example that we can relate to is travel booking systems. For instance, take Kayak, the biggest online site for booking tickets. You enter your destination, and once you select dates and click on search, what you get back are the results from different airlines. How is Kayak communicating with all these airlines? There must be some ways that these airlines are actually exposing some level of information to Kayak. It's through APIs
Example 3: Now open UBER. Once the site is loaded, it gives you the ability to log in or continue with Facebook and Google. In this case, Google and Facebook are also exposing some level of users' information. There is an agreement between UBER and Google/Facebook that has already happened. That's the reason it is letting you sign up with Google/ Facebook.
What Is the Use of APIs?
If I expose a free API, it's not that I am exposing all the information that there is. I have my own criteria like what level of information that I should expose to my user or to the outside world. So, I tie that information and expose it, and now people use it. Tomorrow, they want some extra level of information, and they comfort me and ask me for that. Why should I give it for free? That's when I charge based on the demand.
Think about the development perspective, UBER has an ability to share location where it uses Google Map API there. UBER has to focus on what it is actually doing rather than already existing functionality. It can just plug and play. There is no reinvestment of time to develop the same functionality. That's how people expose some level of APIs to the outside world, and some of them will be charged based on how you are using it.
SOAP vs. REST
What to Test in APIs?
There is a huge need for us to make sure that what we are requesting and what we are getting are matched. If we are requesting some information, we have to make sure that the response is correct. That's where QA/API testers come into the picture. It is our responsibility to make sure that every request is getting proper responses.
This article was originally posted at Test Automation Resources.
Published at DZone with permission of Jefferey Dunn. See the original article here.
Opinions expressed by DZone contributors are their own.