Brand new way to test your API
Project description
python-apitist
Brand new way to test your API
Installation
Actually project is not published on PyPi, so the only way:
pip install python-apitist
Default hooks
- RequestDebugLoggingHook
- RequestInfoLoggingHook
- PrepRequestDebugLoggingHook
- PrepRequestInfoLoggingHook
- ResponseDebugLoggingHook
- ResponseInfoLoggingHook
Example usage
from apitist.hooks import PrepRequestInfoLoggingHook, ResponseInfoLoggingHook
from apitist.requests import session
s = session()
PrepRequestInfoLoggingHook.formatter = "Best formatter {req.method} {req.url}"
s.add_prep_request_hook(PrepRequestInfoLoggingHook)
s.add_response_hook(ResponseInfoLoggingHook)
s.post("https://httpbin.org/post", params={"q": "test"})
Custom Hooks
from requests import Request, PreparedRequest, Response
from apitist.requests import session, RequestHook, PreparedRequestHook, ResponseHook
s = session()
class ReqHook(RequestHook):
def run(self, request: Request) -> Request:
print(request.url)
return request
class PrepReqHook(PreparedRequestHook):
def run(self, request: PreparedRequest) -> PreparedRequest:
print(request.url)
return request
class RespHook(ResponseHook):
def run(self, response: Response) -> Response:
print(response.url)
return response
s.add_request_hook(ReqHook)
s.add_prep_request_hook(PrepReqHook)
s.add_response_hook(RespHook)
s.get("https://ya.ru", params={"q": "test"})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-apitist-0.0.3.tar.gz
(25.3 kB
view hashes)
Built Distribution
Close
Hashes for python_apitist-0.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0d01b3c10e5e36b794e3167d88bb6f647d9785fcceb75b4b1fb769aaab0bd7b |
|
MD5 | 2483f362b050af83248c1f4c32acceb1 |
|
BLAKE2b-256 | 8f6323f9cb81606279269c9c140d2b46f30e3404763ab91cc319eb8e9f2f299e |