Your first scripted API check: from a manual request to a repeatable test
You can already send an API request by hand. Learn how to turn one into a script that checks the reply, uses its own data, cleans up, and gives the same answer every run.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: from cooking by feel to a recipe card. The first time you make soup, you taste as you go. It works, but a friend cannot repeat it. So you write a recipe. It gives exact amounts, the steps, and what the soup should taste like. You also say to start with a clean pot and to wash up after.
Daily List is a to-do list app. Tom, the tester, has sent an add-a-task request by hand and seen the reply. Mei, the test lead, asks him to turn it into a script that anyone can run. Leo, the developer, wants it to run every time he changes the code.
The manual request is the cooking by feel. The script is the recipe card. It follows a controlled procedure, checks the reply against declared expectations, uses its own , and arranges cleanup even when a test assertion fails. A repeatable check can still fail when the app or its requirements change.
The tool does not matter at the start. Tom can use a request tool with a scripts tab, or a few lines of Python, or Java. The steps are the same in all of them.
The picture has limits. Soup is eaten, but stays in the app until the script removes it. And a recipe can only check the tastes that you wrote down.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)
PLAIN WORDS · 1 in this section
- repeatable
- able to be done again with the same result
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Turning a manual request into a controlled check of its response and saved state.
- Send it by hand
- Pick what to check
- Write the script
- Make the data fresh
- Prove it can fail
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| Tasting the soup as you cook | The manual request and reply |
| The written recipe card | The script |
| Exact amounts and a taste target | The status and body check |
| A clean pot and fresh ingredients | Fresh made-up data and a clean start |
| Washing up at the end | Deleting the data the script made |
| The cook's hands that carry the order to the stove | The HTTP client library, such as requests, that sends the request and returns the reply |
| The kitchen helper who calls each dish, runs it and says good or bad | The test framework, such as pytest or JUnit, which finds and runs each check |
| A tag on a recipe card saying: this one is a dish to judge | The @Test label above a Java method |
| The shared prep station that every dish starts from | A fixture that does shared set-up, such as getting one login token |
| A kitchen timer | A connect/read timeout such as timeout=10, which is not a total elapsed deadline |
| Judging the soup, not the pot | Testing Daily List, not the library |
WHERE THIS PICTURE STOPS
- Soup is eaten. Test data stays in the app until the script removes it.
- A recipe only checks the tastes you wrote down.
- A cook can smell a problem. A script sees only what it checks.
- A kitchen timer rings and you walk away. A time limit makes the check fail with an error.
HOOK
Taste it, write it down, check it, clean up.
REMEMBER IT THIS WAY
A sequence: the real steps, in order.
: set up fresh data, send the request, then check the reply.
| In the trick | What it stands for |
|---|---|
| Arrange | Fresh made-up data and a clean start, often from a fixture |
| Act | Send the request |
| Assert | Check the status and key fields of the reply |
TELL A FRIEND
Turn the manual request into with controlled data and declared expectations. Read back saved state, protect credentials and arrange cleanup even after failure.
OFTEN MIXED UP WITH Reading an API automation script. That lesson teaches you to read a script that someone else wrote. This lesson teaches you to build your own from a manual request.
PRACTISE AND KEEP
Sources for this topic — 17 sources
- Market practice
Write scripts to test API response data in Postman (Postman Learning Center) ↗ — Postman · Per the search excerpt, a test is written with a name and a function, and it fails if any check inside fails; checks use the Chai expect style (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Postman test script examples (Postman Learning Center) ↗ — Postman · Shows a named test that checks the response status code, and a test that reads the body as JSON and checks a field (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read as a search excerpt only. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Store and reuse values using variables (Postman Learning Center) ↗ — Postman · Per the search excerpt, variables come in five scopes: global, collection, environment, data and local; the narrowest scope wins (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Quickstart (Requests documentation) ↗ — Python Requests · Shows reading the status code, calling json() to decode the body, raise_for_status() for error codes, and that a decoded body does not mean the call succeeded (search excerpt, page not opened)
Primary publisher body opened and relevant sections read on 6 November 2026; selected-section reading, not a claim every page or external link was read. See docs/research/v16-testing-automation-literacy-audit-20261106.md for exact sections, version and limitations.
- Market practice
Get started (pytest documentation) ↗ — pytest development team · pytest finds test functions whose names start with test_ in files named test_.py or _test.py, and a plain assert statement is enough because pytest reports the values behind a failed assert (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Usage (Representational State Transfer (REST) Assured library wiki) ↗ — Representational State Transfer (REST) Assured project (GitHub wiki) · A Java library for testing web APIs with a given, when, then layout: given holds the request set-up, when sends the request and then checks the reply (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.
- Market practice
What is the easiest tool to learn for API Automation Testing? (Ministry of Testing forum thread) ↗ — Ministry of Testing · Members mostly name Postman as the easiest start, with a low learning curve and little code, and point to a Java library for testers who can program (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read as a search excerpt only. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
HyperText Transfer Protocol (HTTP) response status codes (Mozilla developer docs) ↗ — Mozilla (developer documentation) · Status codes come in five classes: informational, success, redirection, client error and server error (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
JUnit 5 user guide (JUnit documentation) ↗ — JUnit team · JUnit Jupiter is the JUnit 5 model for writing tests; the @Test annotation marks a method as a test, and the Assertions class holds checks such as assertEquals (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page for the 5.14.0 guide as listed in a search; read as a search excerpt only. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
TestNG documentation (Welcome to TestNG) ↗ — TestNG project · A TestNG suite is one XML file; each test in it lists classes; a method annotated @Test is a test method; before and after annotations wrap tests, tests in a group, or the whole suite (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read as a search excerpt only. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
How to invoke pytest ↗ — pytest · r8a-pytest-invoke (node ids with ::, -k expressions). Search excerpt, page not opened.
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Parameters (TestNG documentation) ↗ — TestNG · A method annotated as a data provider returns arrays of parameters that a test method receives by name (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Test scripts (Postman documentation) ↗ — Postman · Opened body: editing a post-response test and choosing Refresh results reruns tests against the latest response without sending the request again.
Relevant page body opened and read. Refresh results runs the edited response checks against the latest reply without sending a new request. The fresh-request decision in Daily List is an editorial teaching inference.
- Market practice
Quickstart (Requests documentation) ↗ — Python Requests · Requests2.34.2 Quickstart,Timeouts:socket inactivity rather than total elapsed download deadline (relevant primary passages opened6November2026).
Primary publisher body opened and relevant sections read on 6 November 2026; selected-section reading, not a claim every page or external link was read. See docs/research/v16-testing-automation-literacy-audit-20261106.md for exact sections, version and limitations.
- Market practice
Quickstart (Requests documentation) ↗ — Python Requests · Complete Requests2.34.2 Quickstart body actually read 7 November 2026: response/JSON/status distinctions and connect/read inactivity timeout behavior. Runnable exercise separately executed with Requests2.32.5, not a latest-version claim.
Primary publisher body opened and relevant sections read on 6 November 2026; selected-section reading, not a claim every page or external link was read. See docs/research/v16-testing-automation-literacy-audit-20261106.md for exact sections, version and limitations.
- Market practice
pytest fixture guide ↗ — pytest-dev contributors · Current pytest requesting/scope and complete teardown/finalizer units actually read 7 November 2026; test assertion failure still runs yielded fixture teardown. Setup failure before a known created ID is separately limited.
Selected actual primary passages read, including the specific fixture/marker/collection boundaries described. Daily List rules, people and paths are synthetic; no pytest/xdist execution or complete production fixture design is claimed. Live documentation has no fixed edition claimed.
- Market practice
How to invoke pytest ↗ — pytest · Complete current pytest invocation guide body actually read 7 November 2026: node IDs and -k expressions/name matching. Older source registry excerpt notes retain their historical scope; runnable exercise separately executed with pytest8.4.2.
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.