Simple API wrapper.
Reason this release was yanked:
faulty import statements
Project description
Wrapi
Wrapi provides:
- a Pythonic wrapper
wrapi.WrAPIaround a Swagger 2.0 API documentation object that allows to conveniently send requests to the API's endpoints and receive their responses, - and a Pydantic specification of the documentation object,
wrapi.SwaggerDoc, which is a relaxed model of Swagger 2.0 directly parseable using the build-injsonlibrary.
Basic Usage
Parse a Swagger JSON File
from wrapi import SwaggerDoc
import json
with open("path_to_swagger", "r") as f:
data = json.load(f)
swagger = SwaggerDoc(**data)
Send Requests to an API
from wrapi import WrAPI
api = WrAPI(swagger)
r = api.request(
"endpoint_path",
{
"query": {
# query params here as key-value dicts
},
"path": "path_param",
"payload": {
# payload params here as key-value dicts
}
}
)
Full Example
from wrapi import SwaggerDoc, WrAPI
import json
with open("path_to_swagger", "r") as f:
data = json.load(f)
swagger = SwaggerDoc(**data)
api = WrAPI(swagger)
r = api.request(
"endpoint_path",
{
"query": {
# query params here as key-value dicts
},
"path": "path_param",
"payload": {
# payload params here as key-value dicts
}
}
)
A full API documentation is available at wrapi-documentation.onrender.com.
Advanced Options: Resend Requests
The request method of wrapi.WrAPI allows to specify an additional parameter retry_responses (default [429]). When a response from this list of response codes is received, it resend the request after wait_time seconds (default 0.1) until a different response is received or until there have been max_attempts attempts (default 100).
This project was initialised with Cookiecutter.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wrapipy-1.0.0.tar.gz.
File metadata
- Download URL: wrapipy-1.0.0.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.2 Linux/6.12.20-2-MANJARO
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
950849248ce4e06d5c9b0c8d76ff9f37d6b9d1f1475755c8aa1ba3e85977e9e6
|
|
| MD5 |
a124f9bd151fa535b1f94d38c201ffbb
|
|
| BLAKE2b-256 |
3cf21a92e6850550b24a17abfa6ee240b0b3f857e10842d6be22709b0da3c5e7
|
File details
Details for the file wrapipy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: wrapipy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.2 Linux/6.12.20-2-MANJARO
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ffdaec666f9db57b64bd86fc57a6ca59fb69abaf286f2448b1dc1410c2b42a1
|
|
| MD5 |
decf2be673b5c408ae6fa5d79c96bdd7
|
|
| BLAKE2b-256 |
09959524318e898fae023e7cfdf346649ea8b26b600a34b16143513ece68eece
|