Skip to main content

The short and sweet way to create an API client

Project description

Tiny API Client 🐝

License: GPL  v2

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

  • 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

Installation

pip install tiny-api-client

Documentation

You can find the documentation at https://tiny-api-client.readthedocs.io

License

License: LGPL  v2.1

This software is distributed under the Lesser General Public License v2.1, more information available at the Free Software Foundation.

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

tiny-api-client-1.2.0b1.tar.gz (46.7 kB view details)

Uploaded Source

Built Distribution

tiny_api_client-1.2.0b1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file tiny-api-client-1.2.0b1.tar.gz.

File metadata

  • Download URL: tiny-api-client-1.2.0b1.tar.gz
  • Upload date:
  • Size: 46.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for tiny-api-client-1.2.0b1.tar.gz
Algorithm Hash digest
SHA256 9b6de7a1d6f63d8dbac2f9679ab425a96dade3bd94cb9e8ce4cfc1ead65d3c66
MD5 4d2eff1f4462aa7e2e8797875eb2e8b8
BLAKE2b-256 88c26c39fa26ffae953d1735c08c42242ecac6ee64da51b8a26430f4da99066c

See more details on using hashes here.

Provenance

File details

Details for the file tiny_api_client-1.2.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for tiny_api_client-1.2.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 28a270d50bd2970221450b4de92c8b165f72d7f9e9951322d13b1387e70117d4
MD5 7c8ab46ae7d6287d779e2ea3241b2540
BLAKE2b-256 32d8f68defdcd052e4d3ab29ee9cbb6c317af292ce2c66b6f4abcf95be222c3a

See more details on using hashes here.

Provenance

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