API Testing using POSTMAN Tool
API (Application Programming Interface):
An API is a set of rules and protocols that allows two different software programs to
communicate and exchange data with each other.
API Testing:
API testing is a type of software testing that validates the functionality, reliability,
performance, and security of Application Programming Interfaces (APIs).
POSTMAN Tool:
Postman is an Application Programming Interface (API) testing tool.
Postman was designed in the year 2012 by software developer and entrepreneur
Abhinav Asthana to make API development and testing straightforward.
Postman has the feature of sending and observing the Hypertext Transfer Protocol
(HTTP) requests and responses.
Example with Library API:
created a mock Library API using [Link] with fields like bookName, author,
publishedBy, publishedYear, and available.
Project Creation:
Go to: [Link]
Log in (Google login works).
Click Create Project → give a project name (your name/project-specific).
Set API Prefix: v1 → Click Create.
Resource Creation:
Inside project, click Create Resource (New Resource).
Resource name: library → Click Create.
Schema Definition:
Define schema fields using UI-based editor:
bookName → String
author → String
publishedBy → String
publishedYear → Number
available → Boolean
Add Records (Populate Data):
Go to Records(data) tab in library resource.
enter sample book data:
Example:
bookName → Clean Code
author → Robert C. Martin
publishedBy → Prentice Hall
publishedYear → 2008
available → true
API Testing in Postman:
Base URL: [Link]
GET (Read Data)
Method: GET
URL: [Link] → fetch all books
URL: [Link] → fetch book by
ID
POST (Create Data)
Method: POST
URL: [Link]
Body (raw → JSON):
{
"bookName": "Refactoring",
"author": "Martin Fowler",
"publishedBy": "Addison-Wesley",
"publishedYear": 1999,
"available": true
}
PUT (Update Data)
Method: PUT
URL: [Link]
Body (raw → JSON):
{
"bookName": "Clean Code",
"author": "Robert C. Martin",
"publishedBy": "Prentice Hall",
"publishedYear": 2008,
"available": false
}
DELETE (Remove Data)
Method: DELETE
URL: [Link]