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

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

Uploaded Source

Built Distribution

api_session-1.3.3-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: api_session-1.3.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.7 Linux/5.15.0-1036-azure

File hashes

Hashes for api_session-1.3.3.tar.gz
Algorithm Hash digest
SHA256 4da4f2eed046170efc5e2cf964d5984771259c836f18775fd90b06f8b54ef660
MD5 99861dac75d83773ef2c1d8951556b47
BLAKE2b-256 3cd28503fd82d56f7b32fb1a7cd739fc0add63db6e4887945ce2d9dc8d3f3163

See more details on using hashes here.

File details

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

File metadata

  • Download URL: api_session-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.7 Linux/5.15.0-1036-azure

File hashes

Hashes for api_session-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a282b64197ef8525c751afa5c4e7788df36535b5823ab86213fd83399bc04992
MD5 f6f3b7b719b84b122b2dccc391876581
BLAKE2b-256 101c7d2adcff9b74072a839ec4222eaba922a2069377c76c6603edccb6768c1f

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