Skip to content

realerikrani/baseclient

Repository files navigation

baseclient

Foundation for building API clients. A wrapper around requests which is licensed under the Apache License 2.0. See the LICENSE file for more details. The original NOTICE file is included in this project and extended with this project's notice.

import requests
from realerikrani.baseclient import BaseAdapter, BaseClient


adapter = BaseAdapter()
with requests.Session() as session:
    baseclient = BaseClient(session=session, adapter=adapter, url=YOUR_BASE_URL)
    YourCustomClient(baseclient)
@dataclass
class YourCustomClient:
    http_client: BaseClient

    def create(self: Self, name: str) -> YourModel:
        url = f"{self.http_client.url}/things"

        response = self.http_client.post(
            url, data={"name": name}, auth=None
        ).json()
        return YourModel.make(response["thing"])

About

Foundation for building API clients. A wrapper around requests

Resources

License

Stars

Watchers

Forks

Contributors