requests.Session to work with JSON APIs
Project description
api-session
api-session is a small module providing an extended requests.Session
class to work with JSON APIs.
We use it at Bixoto as a basis for JSON API clients such as PyMagento or PyBigBuy.
It aims at factoring the common parts of these clients while staying very lightweight (<100 SLOC).
Features
- base URL: the base API URL is given only once on object creation; subsequent calls use
.get("/path")
- read-only flag: if given, prevents the API from doing
POST
and similar calls - offline flag: if given, prevents the API from doing any call. This is useful for tests.
requests.Session
inheritance: the class inherits fromrequests.Session
, so it stays 100% compatible with it
Install
pip install api-session
Dependency: Python 3.8+.
Usage
from api_session import APISession
client = APISession("https://httpbin.org")
client.get_json_api("/get")
# => {...}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
api_session-1.3.4.tar.gz
(4.1 kB
view details)
Built Distribution
File details
Details for the file api_session-1.3.4.tar.gz
.
File metadata
- Download URL: api_session-1.3.4.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.0 CPython/3.9.16 Linux/6.2.0-1015-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d04a0d8e444b3eae699ac434c2d175c48df4825739efe1297ab3160e379a3f0 |
|
MD5 | 1f7733f4bb6b90eff0a0fe171aa08a08 |
|
BLAKE2b-256 | d02159b5f593af1ff265ffc6985036e4c6a840ee90e374ef78c1accee7d5fb80 |
File details
Details for the file api_session-1.3.4-py3-none-any.whl
.
File metadata
- Download URL: api_session-1.3.4-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.0 CPython/3.9.16 Linux/6.2.0-1015-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f86f7887fd779504d6e6112c771a909cd8ad7784707dfdafc4f0b9168bd32460 |
|
MD5 | 345a3139a6e908ee0846ccc49c74ce0f |
|
BLAKE2b-256 | 66e70ff2c6edc31f889f750b44afea53613751ff3d0cbe34e16798d658992ed4 |