Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/falsedev/instant-api-client
Create API wrappers/clients in minutes, enjoying both blocking and async interfaces from one codebase!
https://github.com/falsedev/instant-api-client
api client python
Last synced: about 1 month ago
JSON representation
Create API wrappers/clients in minutes, enjoying both blocking and async interfaces from one codebase!
- Host: GitHub
- URL: https://github.com/falsedev/instant-api-client
- Owner: FalseDev
- License: mit
- Created: 2021-02-03T11:30:32.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-06T07:17:58.000Z (over 3 years ago)
- Last Synced: 2024-09-14T22:30:26.783Z (2 months ago)
- Topics: api, client, python
- Language: Python
- Homepage: https://pypi.org/project/instant-api-client
- Size: 15.6 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```py
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