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.2.tar.gz
(5.8 kB
view details)
Built Distribution
File details
Details for the file tealeaf-0.0.2.tar.gz
.
File metadata
- Download URL: tealeaf-0.0.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 849047184adb4eaa8f4f486a1d5de636c65d44b64eb910ab9d2105aeec22476c |
|
MD5 | 5b69eaf966a17c8683d133e30013993e |
|
BLAKE2b-256 | 44ed26cd056f5fad72c39e9c45aab7125e96ed1f623519db53c6f42ecf7e317f |
File details
Details for the file tealeaf-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: tealeaf-0.0.2-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d8cedecb84f3d7e336189bd188690ddb7f03656ad1f9260c59e794be1e175c6 |
|
MD5 | 5d78c5d9a59f11c547d9d13b5a2c578d |
|
BLAKE2b-256 | f15cd3da28c14645288e018d05948643aeaba15829539a1a4e61f9db21abf23a |