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.
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.1.0.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file api-session-1.1.0.tar.gz
.
File metadata
- Download URL: api-session-1.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.7 Linux/5.11.0-1028-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7828137a6afa93bbda93e5cbc18403af37b4893ec3be114ab4ce5862acacea6 |
|
MD5 | 4b056e86b8b09eb262023378ac24e096 |
|
BLAKE2b-256 | 2d4b2aa4d39301dbb69ea8b479fc63866cbca9bfa5068290462a04301673c955 |
File details
Details for the file api_session-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: api_session-1.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.7 Linux/5.11.0-1028-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 897bce78a6bc09d78031182363563e904991cef695fad81f157945319ade881c |
|
MD5 | ec611a4dfdbd6cd08be03d9e493a7dfb |
|
BLAKE2b-256 | 3b36fb606ffcad23a198a98d8b75f24dfd2a11088e92fa4e2c3cd2bafe884741 |