Skip to main content

Create API wrappers/clients in minutes, enjoying both blocking and async interfaces from one codebase!

Project description

Introduction

If you've ever tried to make an API wrapper you probably know that the code written can only be used as sync or async, well, not anymore.

Features

  • Lightweight: Extremely lightweight and minimal
  • Easy to use: Implement features in no time with the
  • Async and blocking: Provides both async and blocking calls
  • Test without a server: Since the library internally uses httpx, it can be used to test itself using an ASGI or WSGI application.
  • DRY: Don't repeat yourself, helps avoid code duplication and write reusable code
  • Routing: An APIRouter class with simliar API to APIClient
  • Modular: Create reusable routers that can be added to any client, independant of each other

Example Usage

from apiclient import APIClient, endpoint, Post

class CodeExecClient(APIClient):
  base_url = "https://pathtomysite.com/api/1.0"   # Note the missing / suffix
  @endpoint
  def run(self, language:str, code:str):
    # Do any processing with the data here!
    # Also note the / prefix in the url
    return Post("/execute", params={'lang':language, 'code':code})


# Using the API client
from httpx import Client
client = CodeExecClient(session=Client())
response = client.run("py", "print('hello world!')")

Documentation is under works

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

instant-api-client-0.1.2.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

instant_api_client-0.1.2-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

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