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.
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 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.1.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file api-session-1.3.1.tar.gz
.
File metadata
- Download URL: api-session-1.3.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.7 Linux/5.13.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc7d2ff2958af0e392c62b82e6f9f1a047c125d82a68c77e9c3adadf34422430 |
|
MD5 | 02c4786b68ae95fd8020bde264e37c60 |
|
BLAKE2b-256 | 698e43f01671a6a4861b70e6b6ae0b1acf50065d93f7ef4721cc477269990951 |
File details
Details for the file api_session-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: api_session-1.3.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.7 Linux/5.13.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6d3dd99f278804497ee90562d94703adb2d666e0b3eaccbd2592aebeab0efcb |
|
MD5 | 6fd0e2248f7056616bd28ad2e102d152 |
|
BLAKE2b-256 | 330b8e9e43e70ab925485a0d99bf16f4fd6f986dc5a35a66d7117bd8db360696 |