Meet Postman: Who Else Can Be a Client
What an API and an endpoint are, why the client isn’t only the browser and why a tester needs Postman. Plus: how path parameters differ from query parameters, and what’s in the Postman window.
About the product
Hi! There’s a new task. The team is rebuilding the BB Food catalogue: the server with the new API is ready, but the frontend developers are still working on the catalogue page. The API needs testing right now.
But how do I test it without a page? The browser has nothing to open.
Good question! Requests can be sent from more than just the browser. Kadri will show you a tool testers use every day — Postman.
Hi! Before we open Postman, let’s sort out the words you’ll now be hearing every day.
Alex said the API is ready. What is an API?
An API (Application Programming Interface) is the way programs talk to each other. The server announces in advance: “These are the requests I understand, and this is what I’ll answer.” The client can use only that: it never looks inside the server or into the database.
Picture a grocery shop with a counter. A customer doesn’t walk behind the counter or into the storeroom: they look at the price list and ask for what they need, and the shop assistant takes the order and brings the goods from the storeroom.
- The API is the counter with the price listThe list of what you can ask for and the rules for how to ask.
- The API is part of the serverThe counter isn’t a separate building, it’s part of the shop. In the same way the API isn’t a separate program, it’s part of the server itself: its “entrance” where the server takes requests.
An API tester’s job is to send the server requests from this list and check the answers. And not only correct requests, but broken ones too: with empty fields, wrong data, no authorization.
Let’s check. What is an API?
Developers also keep saying “endpoint”. What’s that?
An endpoint is one specific line of that price list: a method together with a path you can use to reach the server. For example, GET /api/v1/products — “get the list of products”.
The full request address is made of the server’s base address (base URL) and the path. The base address is shared by the whole API, while the methods and paths differ from endpoint to endpoint.
GETmethodhttps://bb-food.eebase URL/api/v1/productspathendpoint=GET+/api/v1/products
All the endpoints with descriptions are usually collected in the API documentation, often in Swagger. Swagger is usually generated automatically from the backend code — the program that runs on the server. That’s why it shows what the server can really do. That’s where a tester starts. Here’s the “price list” of our catalogue:
The same path with different methods means different endpoints: GET /api/v1/products reads the list, while POST /api/v1/products adds a product. The product number goes in place of {id} — we’ll come back to that a bit later.
How many different endpoints are there here?
GET /api/v1/products
POST /api/v1/products
GET /api/v1/products/{id}Now about clients. In the Client-Server series the requests to the API were always sent by the browser. So it’s easy to decide that the client simply is the browser. But that’s not true.
Who else can be the client?
A client is any program that sends a request to a server. The server doesn’t care who contacted it: it only sees the request itself — the method, the address, the headers and the body — and answers it.
A customer opens the catalogue in a browser — the client is the browser. In the mobile app — the client is the app.
Let’s check. A customer’s browser, the shop’s mobile app and a tester’s Postman all send requests to our server. Which of them is the client?
How is a response in Postman different from what you see in the browser?
The server’s response itself is the same. The difference is in how the client shows it.
The browser takes the JSON and draws a page from it: product cards, prices, buttons. Postman draws nothing. It shows the response as it is: the status code, the time, the size and the JSON itself.
[
{"id": 1, "name": "Bananas, 1 kg", "price": 1.49},
{"id": 5, "name": "Rye bread", "price": 1.79}
]A tester needs both: Postman shows what the server answered, and the browser shows what the user saw of it.
The browser and Postman sent the server identical GET /api/v1/products requests. How will the responses differ?
Why would a tester send requests bypassing the browser?
There are several reasons:
- No waiting for the interface — the API can be tested before the page exists. Exactly our case.
- Finding where the bug is — if the response in Postman is right but the page is wrong, the bug is on the client. If it’s already wrong in Postman, the bug is on the server.
- Sending what a form won’t allow — an empty name, a price in letters, someone else’s id, a request without a token. The server must protect itself rather than rely on the form.
- Working faster — no need to go through the whole page every time to check one action.
A customer complains: there’s no rye bread in the catalogue on the website. You send GET /api/v1/products from Postman, and the bread is in the response. Where do you look for the bug?
The form in the admin panel won’t let you type a price in letters. So the server will definitely never save the price “abc”?
By the way, I’ve seen both /api/v1/products/5 and ?sort=price in addresses. Are they the same thing?
Good question — let’s dig a little deeper into the request address. There are two ways to pass data in it.
A path parameter is part of the path itself. In /api/v1/products/5 the number 5 says which product exactly we’re working with. We’ve already met it in PATCH, PUT and DELETE. Without it the address means something else: /api/v1/products is the whole list.
Query parameters come after the ? sign: “key=value” pairs separated by &. They don’t pick a resource, they refine the request: filter, sort, limit the number. /api/v1/products?category=bread&sort=price means “give me products in the bread category, sorted by price”. The order of query parameters doesn’t matter, and often they can be left out altogether.
https://bb-food.eeserver address/api/v1/products/path5path parameterhttps://bb-food.eeserver address/api/v1/productspath?category=bread&sort=pricequery parametersA tip: path answers “which one exactly?” — a specific product, order or user. Query answers “which ones and how?” — a filter, sorting, a page.
You need to get one product — the one with id 7. Which address is right?
A customer chose “bread only, cheapest first” in the catalogue. What will that most likely look like in the address?
Got it! So what can Postman do?
Let’s look at its window. Click any part and I’ll tell you what it is. The “later” tag marks what we’ll cover in detail in the next blocks.
Explored: 0 of 12
Pick a part of the window above.
Request line
On the left you pick the method: GET, POST, PUT, PATCH or DELETE. On the right you type the address. The Send button sends the request — and at that moment Postman becomes the client.
Params
The Query Params table: type sort = price and Postman adds ?sort=price to the end of the address by itself. And if you write /api/v1/products/:id in the address, a Path Variables table appears below — that’s where you set the path parameter, for example id = 5.
Authorization
This is where you say who is sending the request: a token (Bearer Token), a login and password (Basic Auth) or an API key. Remove the token and check that the server answers 401.
Headers
Headers are service information about the request. For example, Content-Type: application/json tells the server that the body is JSON. Postman adds many headers by itself.
Body
The request body for POST, PUT and PATCH. Most often it’s JSON (raw → JSON), sometimes a form with files (form-data). You can send anything here — even what the form on the website won’t let through.
Scriptslater
Small JavaScript programs that run before or after the request. For example, they check by themselves that the response code is 200 and the response has the right field. These are the first steps of automation.
Status, time, size
The response code (200 OK), how many milliseconds the server took to answer and how big the response is. A response that is too slow is also a reason for a bug report.
Response body
What the server sent. Pretty — indented and highlighted, Raw — as it arrived, Preview — as a browser would show it. Next to it are tabs with the response headers and cookies.
Collections
Saved requests organised in folders: for example, “Catalogue”, “Cart”, “Admin panel”. A collection can be shared with the team so that everyone checks the same things.
Environments
Environments and variables. Instead of the address you write {{baseUrl}}, and its value depends on the environment: the test server or the production one. Switch the environment and all requests go to a different server.
History
Every request you have sent, even unsaved ones. You can repeat yesterday’s check in one click.
Import, Runner, Mocklater
Import loads ready-made requests from an API description (OpenAPI, Swagger) or from a cURL command. Runner runs a whole collection at once. A mock server answers with stubs while the real API doesn’t exist yet.
Explored it all, let’s check!
You need to add a product with POST. Where in Postman do you put the new product’s JSON?
You need to check that a product can’t be added without logging in. Where in Postman do you remove the token?
Yesterday you checked a request but forgot to save it. Where can you find it?
The same requests have to go sometimes to the test server and sometimes to production. How do you avoid rewriting the address in each one?
Great! Now you know that Postman is a client just like the browser, and where everything is in its window. Next in this block we’ll send requests ourselves, starting with GET.
Quick reference
API
The rules programs use to talk: which requests the server understands and what it answers. Like a shop counter with a price list: the customer asks for goods from the price list and never goes into the storeroom, and the client uses the API and never goes into the database.
Endpoint
One specific item of an API: a method together with a path, for example GET /api/v1/products. The full address is the base address (base URL) plus the path. The same path with different methods means different endpoints. They are all described in the API documentation, often in Swagger, which is usually generated automatically from the backend code.
Who can be the client
A client is any program that sends a request to a server: a browser, a mobile app or Postman. The server only sees the request and answers identical requests identically.
Postman
A program for sending requests to an API by hand. It shows the response as it is: the status code, time, size, headers and body. A browser, in contrast, draws a page from the response.
Why a tester bypasses the interface
To test the API before the page exists; to find out where a bug is — on the client or on the server; to send data the form won’t let through; to repeat checks faster.
Path and query parameters
A path parameter is part of the path and picks a specific resource: /api/v1/products/5. Query parameters come after ? as key=value pairs joined with & and refine the request: /api/v1/products?category=bread&sort=price.
The Postman window
The request line (method, address, Send), the Params, Authorization, Headers, Body and Scripts tabs, and the response panel. On the left are collections, environments and history.
Collections and environments
A collection is saved requests in folders that can be shared with the team. An environment keeps variables such as {{baseUrl}}: switch the environment and the requests go to a different server.