Script Valley
Postman API Testing: Complete Course
Introduction to Postman and API FundamentalsLesson 1.2

Understanding REST APIs and HTTP Fundamentals

REST API basics, HTTP methods, HTTP status codes, request anatomy, response anatomy, JSON format, API endpoints

Understanding REST APIs and HTTP Fundamentals

Before diving deep into Postman API testing, you need a solid understanding of how REST APIs and HTTP work. Every Postman request is an HTTP message sent to a server โ€” knowing the anatomy of that message helps you build better tests, debug faster, and understand what responses mean.

What is an API?

An API (Application Programming Interface) is a contract between two software systems that defines how they communicate. A REST API (Representational State Transfer) is the most common type of web API. It uses standard HTTP methods to perform operations on resources identified by URLs.

Think of a REST API as a restaurant menu. The menu defines what you can order (endpoints), the waiter takes your request (HTTP client like Postman), the kitchen processes it (server), and you receive your order (response). You do not need to know how the kitchen works โ€” you just need to know how to place the order correctly.

HTTP Methods

MethodPurposeHas BodyIdempotent
GETRetrieve a resourceNoYes
POSTCreate a new resourceYesNo
PUTReplace a resource entirelyYesYes
PATCHPartially update a resourceYesNo
DELETERemove a resourceNoYes

HTTP Status Codes

Every API response includes a status code that tells you the outcome of the request:

  • 2xx โ€” Success: 200 OK (GET/PUT success), 201 Created (POST success), 204 No Content (DELETE success)
  • 3xx โ€” Redirection: 301 Moved Permanently, 304 Not Modified (cached)
  • 4xx โ€” Client Error: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 422 Unprocessable Entity
  • 5xx โ€” Server Error: 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable

Anatomy of an HTTP Request

Every HTTP request has four parts:

  • Request Line: The HTTP method and URL โ€” for example, GET https://api.example.com/users/42
  • Headers: Key-value metadata โ€” Content-Type, Authorization, Accept, and custom headers
  • Query Parameters: Key-value pairs appended to the URL after ? โ€” for example, ?page=1&limit=20
  • Body: The data payload sent with POST, PUT, or PATCH requests โ€” typically JSON

Anatomy of an HTTP Response

  • Status Line: HTTP version and status code โ€” HTTP/1.1 200 OK
  • Headers: Content-Type, Content-Length, Cache-Control, Set-Cookie, and others
  • Body: The response data โ€” usually JSON for REST APIs

JSON โ€” The Language of REST APIs

JSON (JavaScript Object Notation) is the universal data format for REST APIs. It is lightweight, human-readable, and supported by every programming language. In Postman, responses are automatically parsed and displayed as formatted, syntax-highlighted JSON.

{
  "id": 42,
  "name": "Ashish Kumar",
  "email": "ashish@scriptvalley.com",
  "role": "admin",
  "createdAt": "2024-01-15T10:30:00Z"
}

Base URL and Endpoints

A REST API URL has two parts: the base URL and the endpoint path. The base URL identifies the server โ€” for example, https://api.yourapp.com/v1. The endpoint path identifies the specific resource โ€” /users, /users/42, /users/42/orders. Combining them gives you the full request URL.

Key Takeaways

  • REST APIs use HTTP methods: GET (read), POST (create), PUT (replace), PATCH (partial update), DELETE (remove).
  • Status codes tell you the result: 2xx = success, 4xx = client error, 5xx = server error.
  • Every HTTP request has a method, URL, headers, and optionally a body.
  • JSON is the standard data format for REST API requests and responses.

Up next

Postman Installation and Interface Walkthrough

Sign in to track progress

Understanding REST APIs and HTTP Fundamentals โ€” Introduction to Postman and API Fundamentals โ€” Postman API Testing: Complete Course โ€” Script Valley โ€” Script Valley