The short and sweet way to create an API client
Project description
Tiny API Client 🐝
Write JSON API Clients in Python without the fluff, pumped full of syntactic sugar
from tiny_api_client import api_client, get, post, delete
@api_client('https://example.org/api/public/v{version}')
class MyAPIClient:
@get('/users/{user_id}')
def find_user(self, response):
return response
@post('/notes')
def create_note(self, response):
return response
@delete('/notes/{note_id}/attachment/{attachment_id}', version=3)
def delete_note_attachment(self, response):
return response
>>> client = MyClient()
>>> client.find_user(user_id='PeterParker')
{'name': 'Peter', 'surname': 'Parker', ...}
>>> client.create_note(data={'title': 'New Note', 'content': 'Hello World!'})
{'id': ...}
>>> client.delete_note_attachment(node_id=...)
Features
- Instance-scoped
requests.Session()
with connection pooling and cookie preservation - JSON is king, but XML and raw responses are fine too
- Endpoints can use GET, POST, PUT, PATCH, DELETE
- Route parameters are optional
- Easy integration with your custom API classes
- Declare endpoints under different API versions
- Can define the API URL at runtime if not available before
- Can set a custom CookieJar to pass with all requests
- Pass along any parameters you would usually pass to requests
- Custom JSON status error handling
- Installable pytest plugin for easy testing
- Excellent support for type checking thanks to a built-in mypy plugin
Installation
pip install tiny-api-client
Documentation
You can find the documentation at https://tiny-api-client.readthedocs.io
License
This software is distributed under the Lesser General Public License v2.1, more information available at the Free Software Foundation.
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
tiny_api_client-1.3.1.tar.gz
(54.4 kB
view details)
Built Distribution
File details
Details for the file tiny_api_client-1.3.1.tar.gz
.
File metadata
- Download URL: tiny_api_client-1.3.1.tar.gz
- Upload date:
- Size: 54.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 432c76b400c9b7bcfe3ac8236b2b087005fe106ad3b0d87c700db8f5a9c140fd |
|
MD5 | aa18ed245ec5e30426cde11f8e9316e4 |
|
BLAKE2b-256 | 58d3c76428547cf9c79208a73dcbd563c4420c8e483a9e43fb3c5de7ad76148d |
File details
Details for the file tiny_api_client-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: tiny_api_client-1.3.1-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dea40dfe247399d07ffce07a096cc903d9362d9574bd2ab9f7754d74362cd533 |
|
MD5 | db296c5c50340f60643798b709e91808 |
|
BLAKE2b-256 | cddf6f974d5046facbea2e1815503b9d6138157fc84f34bcb5d42a39d407e905 |