Before understanding about API, Let's consider some real time scenarios first.
You go to any restaurant for a grand party. A waiter comes to your desk and takes your order. Waiter goes to kitchen and brings up your ordered food. You don't bother how waiter did this. You just worried about your order. In more specific way, You are concerned for your work to be done not how it is done and by whom it will be done.
Let's see an another example. You launch Facebook URL on a browser and enter your credentials. If you provide correct credentials, you should view home page of your account. If you provide wrong credentials, you will see some error message. How it happens actually? When we pass credentials, some information is being sent to Facebook's backend through messenger/channel. These credentials information is validated and response is sent back to end user through messenger.
Let's see an another example. You wanted to book a flight ticket. You generally use a website which shows flights from all flight service providers. E.g. Yatra. When you enter all required details like Source, Destination, Journey date etc and click on search, you can see N number of flights from different airlines. Actually when you provide all details, Yatra sent a message through messenger to all airlines and request flight information as per requirement. Airlines returns list of flight with fare to Yatra and it shows up to end users.
In all above example, you could notice one common thing: "Messenger". This messenger in technical world is called as an Application Programming Interface (API). An API performs what user has requested without exposing internal logic or working of task done. You are able to login to Facebook and use it but you don't get to know how Facebook is working internally. You can also think API as an example of oops concepts called Abstraction. Interface is a point where two systems, subjects, organizations, etc. meet and interact.
"An API is a set of codes which allows two or more than two applications to communicate each other internally or externally and provide a result to end users or to another API.".
An API can call another API or Output of an API can be input for another API.
I got some feedback to explain "internally or externally" from definition of API above.
Suppose you are developing an application and it has many components. A component will communicate to other component to get data or provide data. For example: Login component of Facebook application needs to communicate "Profile" component to get user's data. Here these components will communicate to each other through an API. It is internal communication as both components within same application talking to each others. It is an example of internal communication.
Let's see other aspect now. You download some apps and it will ask you to signup/Login with Facebook on launching app. You click on it to login with Facebook and you are promoted to dialog box where you need to provide some permissions and you are logged in. Here App and Facebook both are different applications but they communicated and it is possible because of APIs. App used facebook open APIs to provide facility to login using Facebook. It is an example of external communication.
TestNG Tutorials 7: How To Create Customized TestNG XML?
Which Programming language we need to learn for API testing?
Your way of explanation is superb !
Please explain how to write/create relative X paths using ascending, descending, preceding, following, following-sibling etc.
Hi Amod…the way you explain the topic is very good and easy to understand.Thanks for your effort.Please make a topic on "What is difference between Rest and Soap". Thanks in advance.
Thanks Robins. Soap based topics are coming soon.
good blog. Requesting you to write more on API testing.
Thanks Amit. Will be adding more posts soon.