REST API Postman and cURL
Reading about APIs teaches the concepts. Sending real requests builds the skill. Two tools cover almost every beginner need: Postman, a visual app, and cURL, a command-line program. Both let you send requests, read responses, and explore any API in minutes.
Why Testing Tools Matter
A browser address bar can only send GET requests. Real APIs need POST, PUT, PATCH, and DELETE, custom headers, and JSON bodies. Testing tools give you full control over each part of a request and show every part of the response, including status codes and headers.
The Request Journey
You type a request
│
▼
┌──────────────────┐ HTTP request ┌──────────────┐
│ Postman or cURL │ ────────────────→ │ API Server │
└──────────────────┘ └──────────────┘
▲ │
│ HTTP response │
└─────────────────────────────────────┘
Status code + headers + JSON body
Postman
Postman offers a window with clear fields for the method, URL, headers, and body. Click Send and the response appears below with its status code, time, and size.
Collections
A collection stores related requests in one folder. A bookstore project might hold requests named List Books, Create Book, and Delete Book. Teams share collections so everyone tests the same calls.
Environments and Variables
Environments store values such as a base URL or token. Write {{baseUrl}}/books in the URL field, and Postman swaps in the value for the active environment. Switching from a test server to a live server takes one click.
Tests
Postman runs small scripts after each response. A script can confirm that the status code equals 200 or that the body contains an id field.
cURL
cURL ships with macOS, Linux, and modern Windows. Every request fits on one line, and you can paste the same line into documentation or a chat with a teammate.
Core Options
| Option | Purpose |
|---|---|
| -X | Sets the HTTP method |
| -H | Adds a header |
| -d | Sends a request body |
| -i | Shows response headers |
| -v | Shows the full conversation in detail |
Example Requests
Read a list of posts:
curl -i https://jsonplaceholder.typicode.com/posts/1
Create a new post:
curl -X POST https://jsonplaceholder.typicode.com/posts \
-H "Content-Type: application/json" \
-d '{"title":"Hello","body":"My first post","userId":1}'
Remove a post:
curl -X DELETE https://jsonplaceholder.typicode.com/posts/1
JSONPlaceholder is a free practice API. It accepts fake writes and returns realistic responses, so you can experiment without risk.
Reading a Response
Check three things in every response. The status code tells you whether the call worked. The headers describe the content type, caching rules, and limits. The body holds the data. A 201 status with a Location header confirms that a new resource exists and shows where to find it.
Choosing Between the Two
- Use Postman to explore a new API, organize many requests, and share work with a team.
- Use cURL for quick checks, scripts, and automated jobs on servers.
Common Beginner Mistakes
Missing Content-Type Header
Servers often reject JSON bodies that arrive without Content-Type: application/json. Add the header to every POST, PUT, and PATCH request.
Quote Problems on Windows
Windows Command Prompt handles single quotes differently from macOS and Linux. Wrap the JSON body in double quotes and escape the inner quotes, or use PowerShell or Postman.
Storing Secrets in Shared Collections
Keep tokens in environment variables and leave them out of exported files. Anyone who receives the file can read what it contains.
