Skip to main content

Simple API wrapper.

Reason this release was yanked:

faulty import statements

Project description

Wrapi

Wrapi provides:

  • a Pythonic wrapper wrapi.WrAPI around 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-in json library.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wrapipy-1.0.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wrapipy-1.0.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

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

Hashes for wrapipy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 950849248ce4e06d5c9b0c8d76ff9f37d6b9d1f1475755c8aa1ba3e85977e9e6
MD5 a124f9bd151fa535b1f94d38c201ffbb
BLAKE2b-256 3cf21a92e6850550b24a17abfa6ee240b0b3f857e10842d6be22709b0da3c5e7

See more details on using hashes here.

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

Hashes for wrapipy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ffdaec666f9db57b64bd86fc57a6ca59fb69abaf286f2448b1dc1410c2b42a1
MD5 decf2be673b5c408ae6fa5d79c96bdd7
BLAKE2b-256 09959524318e898fae023e7cfdf346649ea8b26b600a34b16143513ece68eece

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page