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.

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

Uploaded Source

Built Distribution

api_session-1.0.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file api-session-1.0.0.tar.gz.

File metadata

  • Download URL: api-session-1.0.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.7 Linux/5.11.0-1025-azure

File hashes

Hashes for api-session-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1c15906ea686410cd5acbf67a3384fc5abbc9da4d5475cffe298ce61cdd7a746
MD5 5545a97da1604fa8a09ffed2d6e8c33b
BLAKE2b-256 e38b0b33868e06e4a69d7b3b7779f9a6bfe266e5a1555811940ddeee0cae750a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: api_session-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.7 Linux/5.11.0-1025-azure

File hashes

Hashes for api_session-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91d2b0c4a64c09e4b90cd83ce8f5e4f001d83e47dbff3cc45be94f38539ca42d
MD5 4f54b44130331765cefcdfed6631c4e8
BLAKE2b-256 6f15c44d2222ec1585aaa3cbe466588f499b94dd39300e003c698950b3064e97

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