Skip to main content

Quality Assurance

Introduction to API… The effortless definition to understand

What is an API?

API (Application Programming Interface) is an interface/intermediate software that allows two different applications to talk to each other.

 

Working Of Api

 

WWW and Remote Servers

  • A WWW (World Wide Web) is about communication between Clients and Servers
  • Clients are browsers.
  • Servers are database/backend of the websites.
  • Every page on the internet is stored somewhere on a remote server.
  • When you hit www.perficient.com in a browser, a request goes out to Perficient’s remote server and it sends back the required response to the browser.
  • As a result, the browser interprets the code and displays the page.

Request And Response

 

Request, Response, and API:

Api Example

Pretend you’re at a table in a restaurant, with a menu in front of you.
In the kitchen, food will be prepared.
So, how are you going to order your food and have it delivered to you from the kitchen?
WITH THE HELP OF WAITER…..

Your order is referred to as a Request.
API is the Waiter.
The kitchen is the server.
The Response is the order/food from the kitchen.

 

Request Failures:

  • Instead of ordering food, order a mobile in a restaurant.
  • The Waiter/Kitchen will deny your order (request).
  • You will get only food in a restaurant not mobile.
  • You will get the proper response if and only if it is available on the server otherwise will get errors or failures.
  • Sometimes you order the correct food, but the waiter/server still denies your request because of particular reasons they are not able to prepare that food.

 

Exercise to understand the working of API:

  • Enter www.perficient.com or any other website you are familiar with into your browser.
  • Take note of how the page loads and displays a Google homepage within a fraction of a second.
  • That means our request was proper, and we received a proper response.
  • Now, in the browser, type www.perficient.google.
  • It will display an error message.

 

HTTP/URL:

Http

Host: It can be any website.

Resourcepath: It’s similar to a directory or folder structure that contains data.

Requested parameters: It is a query that is used to retrieve sorted data from a server.

So, it will return data related to animals only, if and only if the value of ‘cors’ in the response is set to ‘yes’.

 

HTTP Methods:

Every API made to the server, uses following types of methods –

  • GET – To retrieve data from the server.
  • POST – To add new data/resource into the server.
  • PUT – To update the existing data in the server.
  • DELETE – To delete the data/resource from the server.

 

HTTP Status Codes:

When we receive a response, it contains some status code:

200: OK – The request was successful and we have got the requested data in the Response.

500: Internal Server Error – Because the server has run into an issue so, it is unable to resolve it.

404: Not Found – The server is unable to locate the requested resource.

401: Unauthorized – The requested resource requires authorization or you are using the incorrect credentials.

And more ………

 

“Anyone who stops learning is old, whether at twenty or eighty.”
Henry Ford

Tags

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Imranur Raheem

Imranur Raheem works as a QA Technical Consultant at Perficient, where he is involved in an API testing and AEM testing project and has 5+ years of testing experience. Enthusiastic about acquiring new talents and passing those skills on to others. Sharing his talent via his blog.

More from this Author

Follow Us