Enough theory. Let's actually call an API. Right now. No Postman, no fancy tools. Just your terminal and a command called curl. Every developer and tester should know curl — it's available on every Mac, Linux, and modern Windows machine.
curl (Client URL) is a command-line tool that sends HTTP requests. Think of it as a text-based Postman. You type a command, it hits the API, and prints the response. No GUI, no installation, no signup.
Open your terminal (Terminal on Mac, Command Prompt or Git Bash on Windows) and type this:
# Fetch a single post from JSONPlaceholder (a free test API)
curl https://jsonplaceholder.typicode.com/posts/1You should see something like this:
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur..."
}Congratulations. You just made an API call. You sent a GET request to a server, and it returned JSON data. That's literally what API testing is — send a request, check the response.
# Pipe through python's JSON formatter for readable output
curl -s https://jsonplaceholder.typicode.com/posts/1 | python3 -m json.tool
# -s = silent mode (hides progress bar)# Fetch all users (returns an array of 10 users)
curl -s https://jsonplaceholder.typicode.com/users | python3 -m json.tool
# Fetch posts by a specific user (query parameter)
curl -s "https://jsonplaceholder.typicode.com/posts?userId=1" | python3 -m json.toolWhen using query parameters with curl, wrap the URL in double quotes. The & character has special meaning in the terminal, and without quotes, your command will break.
# Create a new post
curl -s -X POST https://jsonplaceholder.typicode.com/posts \
-H "Content-Type: application/json" \
-d '{
"title": "My First API Test",
"body": "This post was created via curl!",
"userId": 1
}' | python3 -m json.tool
# -X POST = use POST method
# -H = add a header
# -d = request body (data)The response will include an "id": 101, which means the server created a new resource. You just tested a POST endpoint.
# -v (verbose) shows EVERYTHING — method, headers, status code
curl -v https://jsonplaceholder.typicode.com/posts/1
# You'll see lines like:
# > GET /posts/1 HTTP/2 ← request method + path
# > Host: jsonplaceholder... ← request headers
# > Accept: */*
# < HTTP/2 200 ← response status code
# < content-type: application/json ← response headers
# { "userId": 1, ... } ← response body| Flag | Purpose | Example |
|---|---|---|
| -X | Set HTTP method | -X POST, -X PUT, -X DELETE |
| -H | Add a header | -H "Content-Type: application/json" |
| -d | Send request body | -d '{"name": "test"}' |
| -v | Verbose output (shows headers) | curl -v url |
| -s | Silent mode (no progress bar) | curl -s url |
| -o | Save response to a file | -o response.json |
| -w | Show response metadata | -w "%{http_code}" |
GET all posts: curl -s https://jsonplaceholder.typicode.com/posts | python3 -m json.tool | head -30
GET a single user: curl -s https://jsonplaceholder.typicode.com/users/3 | python3 -m json.tool
GET comments on post 1: curl -s "https://jsonplaceholder.typicode.com/posts/1/comments" | python3 -m json.tool
POST a new post (from Step 4 above) and check the returned id
PUT to update post 1: curl -s -X PUT https://jsonplaceholder.typicode.com/posts/1 -H "Content-Type: application/json" -d '{"title": "Updated", "body": "Changed", "userId": 1}' | python3 -m json.tool
DELETE post 1: curl -s -X DELETE https://jsonplaceholder.typicode.com/posts/1 -v
JSONPlaceholder is a fake API — it pretends to create/update/delete but doesn't actually persist data. It's perfect for learning and testing. In the next chapter, you'll use Postman which is much more convenient for real work.
Q: What is curl and when would you use it?
A: curl is a command-line tool for sending HTTP requests. I use it for quick API smoke tests, debugging in production servers (where Postman isn't available), writing shell scripts that call APIs, and verifying endpoints during development. It's available on every operating system and doesn't need installation. For serious testing I use Postman or RestAssured, but curl is always my first tool for a quick check.
Key Point: curl is your simplest API testing tool. GET reads, POST creates, -v shows everything. Practice these commands until they feel natural.