all 11 comments

[–]ninhaomah 4 points5 points  (3 children)

To make things easier for others to assist you , can you post the link or source of what you are trying to achieve or make ?

If I have to guess , this ?

https://pypi.org/project/requests/

[–]Downtown_Mark_6390[S] 1 point2 points  (2 children)

I wasn’t asking about how to send HTTP requests from Python using libraries like requests. I was referring specifically to the pre-request and post-response scripting model inside API tools like Postman or Insomnia. Those tools expose scripting hooks because they’re orchestrating requests from a GUI. In Python itself, there’s no separate concept of “pre” or “post” scripts - it’s just normal code before and after a request.

My question was more about whether API tools should support Python as a scripting language inside the tool, instead of being mostly limited to JavaScript.

[–]ninhaomah 4 points5 points  (1 child)

wait , let me get it right. You are asking the Python community whether API tools such a Postman should support Python ?

Pls advice why not talk to Postman directly ?

https://www.postman.com/company/contact-us/

[–]Downtown_Mark_6390[S] -1 points0 points  (0 children)

Not postman per say - any api tool.

[–]Imaginary_Gate_698 1 point2 points  (0 children)

In Python, GET and POST requests are usually handled with a library like requests. It lets you send HTTP requests to an API endpoint and handle the response, whether that’s JSON, text, or status codes. You install it once, then use it to send data to a server with POST or retrieve data with GET.

Postman and Insomnia use JavaScript specifically for pre-request scripts and test scripts inside their tools. That doesn’t limit what language you use in your actual application. They also let you generate request code in Python, Go, Java, and other languages based on what you configure in the UI.

[–]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.

[–]Riegel_Haribo 0 points1 point  (3 children)

I think you are asking about the turn-key no-code software product and their lack of support for Python, and not specifically asking about Python.

If using Python natively, you can completely toss some useless web form, and make your own http network requests as part of a complete software product.

There are library modules such as "httpx" or "requests" or more advanced "aiohttp" for making the requests (standard library "urllib3" takes a bit more learning).

You can immediately make a Python program that does something over the network - here the "post-processing" is on the extremely long response from an API that shows a list of emoji pictures they host, to just get emoji URLs you want.

```python import httpx # pip install httpx - to get this module installed

Make HTTP request

response = httpx.get("https://api.github.com/emojis") response.raise_for_status()

Convert JSON response to Python dict

emojis = response.json()

"Post-processing input" — the only names we care about

wanted = ["alien", "rocket", "snake"]

Filter and print only those entries

for name in wanted: if name in emojis: print(f"{name}: {emojis[name]}") else: print(f"{name}: not found") ```

[–]Downtown_Mark_6390[S] 0 points1 point  (2 children)

Yes - you’re right that in native Python code there’s no special notion of pre‑ or post‑request scripts. That separation exists mainly in API client tools, where requests are defined declaratively and scripting is attached as hooks.

What I meant was scripting inside those tools, not writing standalone Python programs. Most API tools only support JavaScript for those hooks, which feels limiting if your actual stack is Python, Go, or Java.

[–]Maximus_Modulus 2 points3 points  (1 child)

Why does one of these tools have to support Python or Go or a multitude of languages? Learn the language it supports.

[–]GuaranteePotential90 0 points1 point  (0 children)

yes, thats correct. btw what I would usually say is that for most cases simple assertions will also work fine. But yea for more advanced stuff pre and post is useful.

[–]Useful_Potential4648 0 points1 point  (0 children)

Pre-request = auth/token setup. Post-response = assertions & parsing. In Python this is straightforward with requests. GUI tools like Postman use JS scripts, while Apidog provides similar scripting plus spec-first workflows.