Manuals / API Testing / Chapter 7
C · Automation & CI · intermediate · Week 4–6 · Chapter 7 of 11
Code-based API automation
Postman scales to a point; code scales further. Automate with Python requests, JavaScript fetch/axios, or Playwright APIRequestContext — pick one stack.
Path progress57%
Step 1 of 4
Pick your stack
Python: requests + pytest. JS: fetch + Jest/Vitest. Playwright: request fixture for hybrid UI+API teams.
Example
# Python + pytest + requests
import requests
def test_get_user():
r = requests.get("https://jsonplaceholder.typicode.com/users/1")
assert r.status_code == 200
assert "@" in r.json()["email"]Do this now
Install stack. One test: GET users/1, assert status 200 and email contains @.
Was this step clear?
Chapter learning outcomes
- requests / fetch patterns
- pytest or Jest structure
- Setup and teardown
- Assertions on JSON
Clear these before you leave
Side quest
Hybrid awareness
Read Playwright API testing doc. Sketch one UI test that seeds via API.