Selenium WebDriver

API Testing Introduction & Postman Basics

Master API testing fundamentals, HTTP methods, Postman basics, and API validation techniques for comprehensive automation testing.

What is API?

API - Application Programming Interface

Key Definitions

  • • API stands for Application Programming Interface
  • • API is used for communication between 2 or more software components [Front End and Backend Database]
  • • API is used to exchange test data between 2 or more software components
  • • Everyday we use applications like Facebook, WhatsApp, YouTube, Amazon, mobile phones - we use API

API Communication Flow

API Communication Flow - Browser, API, Server interaction diagram showing how frontend communicates with backend through APIs

Understanding how Browser (Frontend), API (Middleware), and Server (Backend Database) communicate with each other

What is API Testing?

API Testing Fundamentals

Core Concepts

  • • API testing is a type of software testing
  • • Inside API testing we focus on business logic of the functionality
  • • API lacks UI (user interface) - no user interface is present
  • • We validate business logic of functionality with the help of different HTTP Requests

🎯 Key Focus Area

Business Logic Testing: Since APIs don't have UI, we concentrate on testing the core business rules, data processing, and functionality logic through various HTTP request methods.

HTTP Request Methods

5 Different Types of HTTP Requests

1. POST Request

Create new data

2. PUT Request

Update entire resource

3. PATCH Request

Partial update

4. GET Request

Retrieve data

5. DELETE Request

Remove data

GET Request - Detailed Explanation

GET Request Purpose

  • • GET Request is used to retrieve entity from the server
  • OR
  • • GET Request used to search user information or open user information as per condition

GET Request Examples

Example URLs and Use Cases

1Search all Employee→ GET Request
http://localhost:3000/employees
2Search Employee as per employee ID→ GET Request with Path Parameter
http://localhost:3000/employees/{id}
3Search Employee as per employee first Name→ GET Request with Query Parameter
http://localhost:3000/employees?firstName='Anuja'
4Search Employee as per employee dept name→ GET Request with Query Parameter
http://localhost:3000/employees?deptName='IT'

📋 URL Source

To hit GET Request we need URL → Swagger Documentation

GET Request Validation Points

Once we hit the Request we verify different things:

1. Status Code / Response Code
Expected: 200
2. Status Line
Expected: 200 OK
3. Response Time or Latency
Performance validation
4. Response Payload or Body
Employee info in JSON or XML Format
5. Response Header
Header validation
6. Response Cookies
Cookie validation

DELETE Request - Detailed Explanation

DELETE Request Purpose & URL

DELETE Request URL Example

http://localhost:3000/employees/{id}

DELETE Request Validation Points

1. Status Code / Response Code
Expected: 204
2. Status Line
Expected: 204 No Content
3. Response Time or Latency
Performance check
4. Response Header
Header validation
5. Response Cookies
Cookie validation

Postman Tool for API Testing

🚀 Postman - API Testing Tool

Postman is a popular API testing tool that allows you to:

  • • Send HTTP requests (GET, POST, PUT, DELETE, PATCH)
  • • Validate API responses and status codes
  • • Test API endpoints with different parameters
  • • Automate API testing with collections and scripts
  • • Monitor API performance and response times

📚 Learning Path

In upcoming lessons, we'll dive deep into Postman usage, API automation, and advanced API testing techniques with practical examples.

Sample Employee Database (JSON)

Employee API Test Data

This is sample JSON data that represents employee information used for API testing examples:

{
  "employees": [
    {
      "firstname": "anuja",
      "lastname": "patil",
      "city": "pune",
      "mobilenumber": 909090,
      "email": "anuja1@gmail.com",
      "id": "1"
    },
    {
      "firstname": "Suraj",
      "lastname": "Yadav",
      "city": "Delhi",
      "mobilenumber": 7777,
      "email": "suraj1@gmail.com",
      "id": "3"
    }
  ]
}

JSON Structure Explanation:

  • • employees: Array containing employee objects
  • • firstname, lastname: Employee name fields
  • • city: Employee location
  • • mobilenumber: Contact number (numeric)
  • • email: Employee email address
  • • id: Unique employee identifier

📄 JSON Server Setup Documentation

JSON Server Setup Guide

Complete documentation for setting up JSON Server for API testing practice. This PDF contains step-by-step instructions for creating a local API server.

JSON Server Setup GuideOpen in new tab

PDF viewer not supported in your browser.

View PDF

Key Takeaways

🔗 API Fundamentals

  • • API enables communication between software components
  • • Used for data exchange between frontend and backend
  • • Essential for modern application architecture
  • • Present in everyday applications we use

🧪 API Testing Focus

  • • Tests business logic without UI dependency
  • • Validates data processing and functionality
  • • Focuses on backend system behavior
  • • Uses HTTP requests for validation

📡 HTTP Methods

  • • GET: Retrieve data (Status: 200 OK)
  • • POST: Create new data
  • • PUT: Update entire resource
  • • DELETE: Remove data (Status: 204 No Content)
  • • PATCH: Partial updates

✅ Validation Points

  • • Status codes and status lines
  • • Response time and latency
  • • Response payload (JSON/XML)
  • • Headers and cookies validation

SDET Mastery

Master Test Automation

Home
CurriculumPracticeQ&ACheatsheet
🍵Buy me a Chai

Knowledge Check

Question 1 of 8

What does API stand for?

Automation Testing Course

Comprehensive course covering Manual Testing, Java Programming, and Selenium WebDriver

🍵Buy me a Chai
Privacy Policy•GitHub
© 2024 Automation Testing Course. All rights reserved.