Metadata-Version: 2.1
Name: apywrapper
Version: 0.1.12
Summary: make wrapper for RESTful API
Home-page: https://github.com/sh1ma/apywrapper
License: GPL-3.0-or-later
Keywords: web,restful,api,wrapper,apywrapper
Author: sh1ma
Author-email: in9lude@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Requires-Dist: dacite (>=1.5.1,<2.0.0)
Requires-Dist: httpx (>=0.14.1,<0.15.0)
Project-URL: Repository, https://github.com/sh1ma/apywrapper
Description-Content-Type: text/markdown

<img src="https://tva1.sinaimg.cn/large/007S8ZIlgy1giomjylcsuj30zk0hsq32.jpg" alt="apywrapper" style="zoom:80%;" />

## apywrapper

![lint](https://github.com/sh1ma/apywrapper/workflows/lint/badge.svg?branch=develop)
[![PyPI version](https://badge.fury.io/py/apywrapper.svg)](https://badge.fury.io/py/apywrapper)

Easy development of RESTful API wrapper

## Feature
- Get response as dataclass object you defined
- Return type can be specified by type annotation of api function
- All parameters (query, path variable, or json data) can be specified at once


## install

```
pip install apywrapper
```

## Example

```python
from apywrapper import Apy, delete, get, patch, post, put
from typing import List, no_type_check
from dataclasses import dataclass


@dataclass
class User:
    name: str
    id: str


@no_type_check
class ApiClient(Apy):
    def __init__(self, token, host="https://example.com/api":
        super().__init__(host, headers={"api-token": token})

    @get("/users/")
    def get_users(self) -> List[User]:
        return {}

    @get("/users/{user_id}")
    def get_user(self, user_id) -> User:
        return {"user_id": user_id}

api = ApiClient(token="xxxxxxxxxxxxxxxxxx")
sh1ma = api.get_user("sh1ma") # return User object
```
