Testing an API Without Writing a Line of Code
Before you wire an API call into an application, you need to know it actually works — the right endpoint, the right headers, the right payload shape. Postman lets you build and fire HTTP requests through a GUI, inspect the raw response, and save the whole thing for reuse, without spinning up a script or a browser console.
Getting Set Up
Download Postman from postman.com/downloads for Windows, macOS, or Linux, or use the browser-based version if you prefer not to install a desktop app. On first launch it will prompt you to sign in or create a free account — you can skip this and use it locally without an account, though signing in enables syncing requests across devices.
Building Your First GET Request
Click New then HTTP Request, or use the + tab at the top of the workspace. You will see a method dropdown (defaults to GET) next to a URL bar. Enter a test endpoint:
https://jsonplaceholder.typicode.com/posts/1
Click Send. The response pane at the bottom shows the JSON body, the HTTP status code (should be 200 OK), response time, and payload size. Postman automatically pretty-prints and syntax-highlights JSON responses, and lets you switch between Pretty, Raw, and Preview views.
Adding Query Parameters
Instead of hand-building a query string in the URL, use the Params tab below the URL bar. Add key-value pairs there — for example userId set to 3 — and Postman appends them to the URL automatically:
https://jsonplaceholder.typicode.com/posts?userId=3
This is more reliable than string-concatenating parameters yourself, especially once you need to URL-encode special characters, which Postman handles for you.
Sending a POST Request With a JSON Body
Change the method dropdown to POST. Go to the Body tab, select raw, and change the type dropdown (usually set to Text by default) to JSON. Enter a payload:
{
"title": "New Post",
"body": "Testing the API from Postman",
"userId": 1
}
Selecting JSON as the body type automatically sets the Content-Type: application/json request header — you can confirm this under the Headers tab. Click Send, and check that the response status is 201 Created for a successful resource creation.
Passing a Bearer Token
Most real-world APIs require authentication. For token-based auth, go to the Authorization tab, set the type dropdown to Bearer Token, and paste your token into the field:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Postman automatically attaches this as an Authorization: Bearer <token> header to the outgoing request — you do not need to add it manually under Headers.
Using Environment Variables
Hardcoding a base URL and token into every request becomes painful once you have dozens of requests, or need to switch between staging and production. Click the environment dropdown in the top-right corner and select Add Environment. Define variables like:
base_url = https://api.staging.example.com
auth_token = eyJhbGciOiJIUzI1NiIs...
Reference them anywhere in a request using double curly braces:
{{base_url}}/v1/users
Switching environments (staging vs. production) then only requires changing the active environment in the dropdown — every request using {{base_url}} updates automatically.
Writing Automated Test Assertions
Click the Tests tab (or Scripts > Post-response in newer Postman versions) and add a JavaScript assertion using Postman's built-in pm object:
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("Response has an id field", function () {
const json = pm.response.json();
pm.expect(json).to.have.property("id");
});
After clicking Send, the Test Results tab shows a pass/fail summary for every assertion. This turns a one-off manual check into something repeatable — useful once you group related requests into a Collection and want to verify them all at once.
Saving Requests to a Collection
Click Save next to the Send button, then save the request into a new or existing Collection — Postman's term for a folder of related requests. Collections keep your work organized by project or API, and can be run end-to-end with the Collection Runner, which executes every saved request in sequence and reports pass/fail for each one's test assertions.
</> code icon near the Send button to auto-generate the equivalent curl command, or a code snippet in Python, JavaScript, or several other languages — a fast way to translate manual testing directly into application code.
Discussion & Insights