Skip to main content

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 from requests.Session, so it stays 100% compatible with it

Install

pip install api-session

Or with Poetry:

poetry add api-session

Dependency: Python 3.8+.

Usage

from api_session import APISession

client = APISession("https://httpbin.org")

client.get_json_api("/get")
# => {...}

Project details


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.6.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

api_session-1.3.6-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file api_session-1.3.6.tar.gz.

File metadata

  • Download URL: api_session-1.3.6.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.9.16 Linux/6.2.0-1018-azure

File hashes

Hashes for api_session-1.3.6.tar.gz
Algorithm Hash digest
SHA256 7bbf07c433db864085e1d36a4e19204c073bbf76e9058babad853a666b978268
MD5 70a1b10173f3c000eb3866e5e357390a
BLAKE2b-256 ba4429c5ab162968f0d7a7daefd4bd91373d0d85d52842d8ef2ab9bf7cc5d5f6

See more details on using hashes here.

File details

Details for the file api_session-1.3.6-py3-none-any.whl.

File metadata

  • Download URL: api_session-1.3.6-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.9.16 Linux/6.2.0-1018-azure

File hashes

Hashes for api_session-1.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e035d2fe3b60e4a0bb2bc14119fb6d3ab22bc04457ce42d8b00a41c5fc46548c
MD5 36b70d775109101ecdc8fea8640222ab
BLAKE2b-256 286a79b4bb06081430331d0a3a1943043ca41940628dfce25f51aa6bd1c2b8aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page