https://github.com/sh1ma/apywrapper
Easy development of RESTful api wrapper
https://github.com/sh1ma/apywrapper
api-wraper python python3 rest-api restful-api
Last synced: 3 months ago
JSON representation
Easy development of RESTful api wrapper
- Host: GitHub
- URL: https://github.com/sh1ma/apywrapper
- Owner: sh1ma
- License: gpl-3.0
- Archived: true
- Created: 2020-08-15T17:19:57.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-17T00:13:31.000Z (over 5 years ago)
- Last Synced: 2025-10-27T04:53:55.612Z (6 months ago)
- Topics: api-wraper, python, python3, rest-api, restful-api
- Language: Python
- Homepage:
- Size: 121 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

## apywrapper

[](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
```