Skip to main content

An HTTP API client for readable code

Project description

Tealeaf

A simple interface for readable Python HTTP clients

  • No dependencies
  • Simple and readable
  • Lightweight

import json
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()

# 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.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

tealeaf-0.0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tealeaf-0.0.1.tar.gz
  • Upload date:
  • Size: 5.8 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.1.tar.gz
Algorithm Hash digest
SHA256 d3d39bec9767bceb59e9fd296e5b7304d0f959d9bb16aebd602201ae7f9659ef
MD5 1425582882a83e1fbcc6d2088c32516c
BLAKE2b-256 9b5962162a71dcbce7dad1c1757131e9e931f61f816174efe22119ea6e770650

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tealeaf-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 81ae8c3cf27f89b46f566e0ca911420335f93b296ec7667cb705af265bbd31e9
MD5 1b1e40074d4ab73bbe5548bc7f8e4d3d
BLAKE2b-256 2ee6b83b43e87275930e044ec26b2323771247e9bf47ac9f7b9b0cfec589e3de

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