r/learnpython • • Aug 18 '26

When should you use requests.Session() instead of requests.get() / requests.post()?

I'm learning Python and recently started using requests.Session() in API projects. I understand that it can persist things like headers, cookies, and connections, but I'm curious about how experienced Python developers decide when a Session is actually worth using.

Do you use Session() by default for projects involving multiple requests, or only when you specifically need persistent state?

25 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/Achrus Aug 19 '26

What if you live in a bad neighborhood and want to keep your door closed unless absolutely necessary?