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
  • 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.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

api_session-1.3.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: api_session-1.3.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.7 Linux/5.15.0-1020-azure

File hashes

Hashes for api_session-1.3.2.tar.gz
Algorithm Hash digest
SHA256 6a378f471a5c4d048ca9869f88242b7162413c93c2ed9ab2c306363bc5329343
MD5 7fe29e3f090654081af21d1f88b767b3
BLAKE2b-256 c1ffd383730499abec0229a86d3c81ca8d8ece3542708ca65699c5fce6710643

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for api_session-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ec5b026b0641d3aac462cd4e5e425268f571eb68af430484d9bff63fa115f823
MD5 73ca9f058cb6b71a2cf6c7af1548c0f9
BLAKE2b-256 d085e2163b052b2aa6a94c43f928b9fd823cb0aa92fbdfefeadab985e96698f5

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