An HTTP API client for readable code
Project description
Tealeaf
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
Release history Release notifications | RSS feed
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.4.tar.gz
(6.5 kB
view details)
Built Distribution
File details
Details for the file tealeaf-0.0.4.tar.gz
.
File metadata
- Download URL: tealeaf-0.0.4.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7972f69f65dd0705fc23065db386202c6afe344f0f6299bb640ecb9323c56953 |
|
MD5 | e8dd067cce13ef85546fe694e4147cd5 |
|
BLAKE2b-256 | 55e31094055d40ca768109e2197aac9953d0c85804e4f4e8615e81918f1c9b97 |
File details
Details for the file tealeaf-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: tealeaf-0.0.4-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 971f449deb1e2e74bc85ad66bcbefb59395a27e01b3119e5fde4ee5bb08db504 |
|
MD5 | 6a723e42071bc33e9f67278bc6fd8830 |
|
BLAKE2b-256 | 520120ce9e5d9224217e7c5b502d0bb92136c4746af325c1dd225bc0bd1f3876 |