Name | ApiQlient JSON |
Version |
0.0.3
JSON |
| download |
home_page | None |
Summary | Quickly create REST clients |
upload_time | 2024-07-17 16:06:57 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.11 |
license | None |
keywords |
rest
api
client
framework
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<p align="center"></p>
<h2 align="center">ApiQlient</h2>
<p align="center">
<a href="https://github.com/rgryta/ApiQlient/actions/workflows/main.yml"><img alt="Python package" src="https://github.com/rgryta/ApiQlient/actions/workflows/main.yml/badge.svg?branch=main"></a>
<a href="https://pypi.org/project/apiqlient/"><img alt="PyPI" src="https://img.shields.io/pypi/v/apiqlient"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://github.com/PyCQA/pylint"><img alt="pylint" src="https://img.shields.io/badge/linting-pylint-yellowgreen"></a>
<a href="https://github.com/rgryta/NoPrint"><img alt="NoPrint" src="https://img.shields.io/badge/NoPrint-enabled-blueviolet"></a>
</p>
## About
Want to develop an easy-to-use API client library for your HTTP server? Maybe you're already using FastAPI and want to share dataclass libraries
between your server and client projects with little to no maintenance involved?
API Quick Client (or ApiQlient) is for you then. Attach custom serializable classes to your endpoints and allow your users
to choose whether they want to use sync or async scheme. You don't need to set up anything else by yourself.
See the [documentation](https://github.com/rgryta/ApiQlient/#Usage) for more information.
## Requirements
ApiQlient utilizes `starlette` as it's base - similarly to FastAPI. Additionally, it requires `yarl` package for URL parsing
and `urllib3` for its' synchronous and `aiohttp` for asynchronous backends.
On top of that it provides several optional functionalities. You can use it with `dataclass_wizard`-defined classes or with `pydantic` model.
If you don't want to define custom classes, you can fall back to using `munch` instead.
## Installation
Pull straight from this repo to install manually or just use pip: `pip install apiqlient` will do the trick.
## Usage
ApiQlient supports both: synchronous and asynchronous execution. The manner of which to use is decided by detecting which
context manager we enter (`with` or `async with`). If we use `with` - `urllib3` will be used. If `async with` - `aiohttp`.
Below you can see and example using dataclass_wizard package.
```python
import asyncio
from dataclasses import dataclass
from apiqlient import ApiQlient
from dataclass_wizard import JSONSerializable, json_field
client = ApiQlient(base_url="https://jsonplaceholder.typicode.com/")
@client.router.get("/{id}")
@dataclass
class JSONPlaceholderDCW(JSONSerializable):
id: int
title: str
completed: bool
user_id: int = json_field("userId")
async def async_main():
async with client:
requests = [client.get(f"/todos/{i + 1}") for i in range(100)]
responses = await asyncio.gather(*[request.response() for request in requests])
objects = await asyncio.gather(*[response.object() for response in responses])
print(f"My fist async object: {objects[0]}")
def sync_main():
with client:
requests = [client.get(f"/todos/{i + 1}") for i in range(100)]
responses = [request.response() for request in requests]
objects = [response.object() for response in responses]
print(f"My first sync object: {objects[0]}")
asyncio.run(async_main())
```
As this project is meant to replicate behaviour of FastAPI and uses starlette as it's core functionality, it also supports
router-based structure. Meaning that you can spread your dataclasses/models between different modules, and attach them to
routers which will later be included into the app. See `example.py` for reference.
### Performance
Performance will differ depending on the environment. However, on my local machine, at the time of writing this, these were the
results from the `example.py` file:
```text
ASYNC
Finished parsing 100 requests in 8.913177967071533 seconds
SYNC
Finished parsing 100 requests in 19.49611806869507 seconds
```
No obvious difference was spotted between using `dataclass_wizard`, `pydantic` or `munch`.
## Development
### Installation
Install virtual environment and apiqlient package in editable mode with dev dependencies.
```bash
python -m venv venv
source venv/bin/activate
pip install -e .[dev]
```
### How to?
Automate as much as we can, see configuration in `pyproject.toml` file to see what are the flags used.
```bash
staging format # Reformat the code
staging lint # Check for linting issues
staging test # Run unit tests and coverage report
```
Raw data
{
"_id": null,
"home_page": null,
"name": "ApiQlient",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "rest, api, client, framework",
"author": null,
"author_email": "Radoslaw Gryta <radek.gryta@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/70/c9/0423656af1dbe2254d743870ca07aae41fe4a2b587ed4e907f71edb23320/apiqlient-0.0.3.tar.gz",
"platform": null,
"description": "<p align=\"center\"></p>\n<h2 align=\"center\">ApiQlient</h2>\n<p align=\"center\">\n<a href=\"https://github.com/rgryta/ApiQlient/actions/workflows/main.yml\"><img alt=\"Python package\" src=\"https://github.com/rgryta/ApiQlient/actions/workflows/main.yml/badge.svg?branch=main\"></a>\n<a href=\"https://pypi.org/project/apiqlient/\"><img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/apiqlient\"></a>\n<a href=\"https://github.com/psf/black\"><img alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"></a>\n<a href=\"https://github.com/PyCQA/pylint\"><img alt=\"pylint\" src=\"https://img.shields.io/badge/linting-pylint-yellowgreen\"></a>\n<a href=\"https://github.com/rgryta/NoPrint\"><img alt=\"NoPrint\" src=\"https://img.shields.io/badge/NoPrint-enabled-blueviolet\"></a>\n</p>\n\n\n## About\n\nWant to develop an easy-to-use API client library for your HTTP server? Maybe you're already using FastAPI and want to share dataclass libraries\nbetween your server and client projects with little to no maintenance involved?\n\nAPI Quick Client (or ApiQlient) is for you then. Attach custom serializable classes to your endpoints and allow your users\nto choose whether they want to use sync or async scheme. You don't need to set up anything else by yourself.\n\nSee the [documentation](https://github.com/rgryta/ApiQlient/#Usage) for more information.\n\n## Requirements\n\nApiQlient utilizes `starlette` as it's base - similarly to FastAPI. Additionally, it requires `yarl` package for URL parsing\nand `urllib3` for its' synchronous and `aiohttp` for asynchronous backends.\n\nOn top of that it provides several optional functionalities. You can use it with `dataclass_wizard`-defined classes or with `pydantic` model.\nIf you don't want to define custom classes, you can fall back to using `munch` instead.\n\n## Installation\n\nPull straight from this repo to install manually or just use pip: `pip install apiqlient` will do the trick.\n\n## Usage\n\nApiQlient supports both: synchronous and asynchronous execution. The manner of which to use is decided by detecting which\ncontext manager we enter (`with` or `async with`). If we use `with` - `urllib3` will be used. If `async with` - `aiohttp`.\n\nBelow you can see and example using dataclass_wizard package.\n\n```python\nimport asyncio\nfrom dataclasses import dataclass\n\nfrom apiqlient import ApiQlient\nfrom dataclass_wizard import JSONSerializable, json_field\n\nclient = ApiQlient(base_url=\"https://jsonplaceholder.typicode.com/\")\n\n\n@client.router.get(\"/{id}\")\n@dataclass\nclass JSONPlaceholderDCW(JSONSerializable):\n id: int\n title: str\n completed: bool\n user_id: int = json_field(\"userId\")\n\n\nasync def async_main():\n async with client:\n requests = [client.get(f\"/todos/{i + 1}\") for i in range(100)]\n responses = await asyncio.gather(*[request.response() for request in requests])\n objects = await asyncio.gather(*[response.object() for response in responses])\n print(f\"My fist async object: {objects[0]}\")\n\n\ndef sync_main():\n with client:\n requests = [client.get(f\"/todos/{i + 1}\") for i in range(100)]\n responses = [request.response() for request in requests]\n objects = [response.object() for response in responses]\n print(f\"My first sync object: {objects[0]}\")\n\n\nasyncio.run(async_main())\n```\n\nAs this project is meant to replicate behaviour of FastAPI and uses starlette as it's core functionality, it also supports \nrouter-based structure. Meaning that you can spread your dataclasses/models between different modules, and attach them to \nrouters which will later be included into the app. See `example.py` for reference.\n\n### Performance\n\nPerformance will differ depending on the environment. However, on my local machine, at the time of writing this, these were the\nresults from the `example.py` file:\n\n```text\nASYNC\nFinished parsing 100 requests in 8.913177967071533 seconds\n\nSYNC\nFinished parsing 100 requests in 19.49611806869507 seconds\n```\n\nNo obvious difference was spotted between using `dataclass_wizard`, `pydantic` or `munch`.\n\n## Development\n\n### Installation\n\nInstall virtual environment and apiqlient package in editable mode with dev dependencies.\n\n```bash\npython -m venv venv\nsource venv/bin/activate\npip install -e .[dev]\n```\n\n### How to?\n\nAutomate as much as we can, see configuration in `pyproject.toml` file to see what are the flags used.\n\n```bash\nstaging format # Reformat the code\nstaging lint # Check for linting issues\nstaging test # Run unit tests and coverage report\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Quickly create REST clients",
"version": "0.0.3",
"project_urls": {
"Bug Tracker": "https://github.com/rgryta/ApiQlient/issues",
"Homepage": "https://github.com/rgryta/ApiQlient"
},
"split_keywords": [
"rest",
" api",
" client",
" framework"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d602ba38efcf0f8143edd13e627cbfc6f43ff238fa0aba0d1643af5d162125b0",
"md5": "9f01f9c4b82fb6ed94c55b2a9b06947a",
"sha256": "70d9d5c2007a7718c01a8c20029d671fb53a9a3cd473824053fb90acc784b033"
},
"downloads": -1,
"filename": "ApiQlient-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9f01f9c4b82fb6ed94c55b2a9b06947a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 8945,
"upload_time": "2024-07-17T16:06:56",
"upload_time_iso_8601": "2024-07-17T16:06:56.340555Z",
"url": "https://files.pythonhosted.org/packages/d6/02/ba38efcf0f8143edd13e627cbfc6f43ff238fa0aba0d1643af5d162125b0/ApiQlient-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "70c90423656af1dbe2254d743870ca07aae41fe4a2b587ed4e907f71edb23320",
"md5": "7b6f1a193f9f62afd19451c9bf303faf",
"sha256": "072a419bd1a4b860dfc838c5f15ae098be3888f24ceb160a8dd9b7b637725a79"
},
"downloads": -1,
"filename": "apiqlient-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "7b6f1a193f9f62afd19451c9bf303faf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 9520,
"upload_time": "2024-07-17T16:06:57",
"upload_time_iso_8601": "2024-07-17T16:06:57.854900Z",
"url": "https://files.pythonhosted.org/packages/70/c9/0423656af1dbe2254d743870ca07aae41fe4a2b587ed4e907f71edb23320/apiqlient-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-17 16:06:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rgryta",
"github_project": "ApiQlient",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "apiqlient"
}