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': 'My New Note', 'content': 'Hello World!'})
{'id': ...}
>>> client.delete_note_attachment(node_id=...)
Features
- 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
- Pass along any parameters you would usually pass to requests
- Can use a session to make all requests
- Custom JSON status error handling
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.0.0.tar.gz
(47.4 kB
view details)
Built Distribution
File details
Details for the file tiny-api-client-1.0.0.tar.gz
.
File metadata
- Download URL: tiny-api-client-1.0.0.tar.gz
- Upload date:
- Size: 47.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76d63f98fcdceb2099271d5e91fddcf760a9d4c051166ca978bb70a1e2f7cf92 |
|
MD5 | 8917e34e98c9ce3ddea4a6d6cbac4030 |
|
BLAKE2b-256 | 1c995190d9e9e564e1e024d42b29363cffde9a9a57a009dd22e6a9fa81f63b1b |
Provenance
File details
Details for the file tiny_api_client-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: tiny_api_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85750176adfc4a54302885f2288618ef0ae2412cd8f46dfc88e0d9c44647262b |
|
MD5 | 4268c4faf9e2da71c3474ede85d3d371 |
|
BLAKE2b-256 | da339a3a8747e181b534190227155cb6b7746218798ba381051189487d667eb3 |