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.5.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for api_session-1.3.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7103c07c968a266d986c107f4c20ba59db7a4ffb0c19b51b15af4a3b0252d4b |
|
MD5 | 8fb6200249f4f9d17e0f105609be86e6 |
|
BLAKE2b-256 | 5f7dc2527e0967dd325da03bbb234d119e13c469714bc8f2fe7fb5fd42adaecd |