Skip to main content

An HTTP API client for readable code

Project description

Tealeaf

license

A simple interface for readable Python HTTP clients

  • No dependencies
  • Simple and readable
  • Lightweight

A simple example

import tealeaf

# simple POST
api = tealeaf.Api('https://www.postman-echo.com')
api.post('/post', {"message": "hello tealeaf"}).json()

# Using bearer tokens
api = tealeaf.Api(
    'https://www.postman-echo.com',
    credentials=tealeaf.BearerToken('my-jwt')
)
api.post('/post', {"message": "hello authorized tealeaf"}).json()

An example with custom auth algorithm:

# define a custom auth handler with a `preprocess_request` method
class CustomCredentialHandler(tealeaf.ApiCredential):

    def __init__(self, secret: str):
        super().__init__()
        self.__secret = secret

    def preprocess_request(self, request: tealeaf.Request):
        # your algorithm goes here and modifies the request object
        request.headers['secret-key'] = f'{request.data}{self.__secret}'
        return request

api = tealeaf.Api(
    'https://www.postman-echo.com',
    credentials=CustomCredentialHandler('my-super-secret')
)
api.post('/post', {"message": "hello custom tealeaf auth"}).json()

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

tealeaf-0.0.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

tealeaf-0.0.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file tealeaf-0.0.3.tar.gz.

File metadata

  • Download URL: tealeaf-0.0.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for tealeaf-0.0.3.tar.gz
Algorithm Hash digest
SHA256 017722342fcc8fa73bb5af21b9bb7c87f3236d1c5b17e1a56fff686f927e3ff2
MD5 82910b60e56fff92ce57ec87dabca282
BLAKE2b-256 c85c2d892c84b593665ef622166a4d20bad01dfe733bad45ebea34866e37f3a7

See more details on using hashes here.

File details

Details for the file tealeaf-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: tealeaf-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for tealeaf-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 36ed0bfe7c150fa3cc135dd5d48435303de84c9ed48bdf6c2b6d929e6ca85edd
MD5 61c03be7a46d7096c81cbef13624ec74
BLAKE2b-256 fee57bd2f67e9e3b21bd6238c27a05443030a7180dfdae8aa7f546dcf4b425fb

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