Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Things You Need to Know About API Testing

DZone's Guide to

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.

· Integration Zone ·
Free Resource

SnapLogic is the leading self-service enterprise-grade integration platform. Download the 2018 GartnerMagic Quadrant for Enterprise iPaaS or play around on the platform, risk free, for 30 days.

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.API Testing Uber Example

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

SOAP has been used for many years, but these days, it's all about REST (Representational State Transfer). If you just go to any job portal and click on "REST API Automation Tester" or ''REST API Testing Jobs," there are tons out there. REST is a kind of API that is actually efficiently being used by many companies like eBay, Amazon, Google. It means that you know REST is in high demand now. There are a few advantages from the development perspective, and REST supports a number of data formats. The most important advantages are the way the requests are sent and how we read the response. There is a specific format that SOAP always uses, which is XML format, whereas REST uses JSON. Now, because JSON is being used, JavaScript object notation is a form of representation. If you click on a JSON format on Google, the objects will be inverted commas followed by the parameters. So, JSON is a way of our communication and a format that is being used for the information exchange such as request versus response.

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. 

Download A Buyer's Guide to Application and Data Integration, your one-stop-shop for research, checklists, and explanations for an application and data integration solution.

Topics:
api testing ,integration ,apis ,api examples ,soap vs rest ,soap ,rest

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}