© Moshe Zadka 2019
Moshe ZadkaDevOps in Pythonhttps://doi.org/10.1007/978-1-4842-4433-3_7

7. Requests

Moshe Zadka1 
(1)
Belmont, CA, USA
 

Many systems expose a web-based API. Automating web-based APIs is easy with the requests library. It is designed to be easy to use while still exposing a lot of powerful features. Using requests is almost always better than using Python’s standard library HTTP client facilities.

7.1 Sessions

As mentioned before, it is better to work with explicit sessions in requests. It is important to remember that there is no such thing as working without a session in requests; when working with the “functions,” it is using the global session objects.

This is problematic for several reasons. For one, this is exactly the kind of “global ...

Get DevOps in Python: Infrastructure as Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.