Metadata-Version: 2.1
Name: httprest
Version: 0.1.0
Summary: A library for making simple REST-like HTTP requests
Home-page: https://github.com/litteratum/httprest
License: MIT
Author: Andrii Nechaiev
Author-email: andrewnech@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Project-URL: Repository, https://github.com/litteratum/httprest
Description-Content-Type: text/markdown

# httprest
`httprest` is a minimalistic framework for communicating with REST APIs.
Its goal is to reduce a boilerplate code required to communicate with APIs.
  * It has the `http` package exposing an HTTP client interface. There is also a client implementation that uses `urllib` under the hood. So no need to use extra libraries like `requests`
  * It has the `api.API` class which may be overridden and used to make API calls

## Usage
```python
from httprest import API

class MyAPI(API):
    def operation(self):
        result = self._request("POST", "/operation/endpoint", json={...})
        if result.ok:
            print(result.json)

api = MyAPI("http://api.com")
api.operation()
```

## Installation
```bash
pip install httprest
```


## HTTP client
The library exposes an `HTTPClient` interface.
There is also an `http.urllib_client.UrllibHTTPClient` implementation that is used by default.

You may define your own HTTP client like this:
```python
from httprest.http import HTTPClient, HTTPResponse

class MyHTTPClient(HTTPClient):
    def _request(...) -> HTTPResponse
```

And then you simply use it in the API client:
```python

api = MyAPI(..., http_client=MyHTTPClient())
```

