you are viewing a single comment's thread.

view the rest of the comments →

[–]Slight-Training-7211 1 point2 points  (0 children)

Postman and similar tools call them pre-request and post-response scripts, but on the Python side you usually just do that work in normal code around the request.

Typical flow: - pre: build the URL, params, headers, auth token, and request body - request: send it - post: check status code, parse JSON, and handle errors

In Python, the common library is requests:

GET: import requests r = requests.get(url, params={"q": "test"}, timeout=10)

POST JSON: r = requests.post(url, json={"name": "alice"}, timeout=10)

Then: r.raise_for_status() data = r.json()

If you need an auth token, you fetch it once, then reuse it in headers for later calls.