Skip to main content

Simple API wrapper.

Project description

WrAPIpy

WrAPIpy provides:

  • a Pythonic wrapper wrapipy.WrAPIpy 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, wrapipy.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 wrapipy 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 wrapipy 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 wrapipy 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 wrapipy.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-2.0.0.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

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

wrapipy-2.0.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file wrapipy-2.0.0.tar.gz.

File metadata

  • Download URL: wrapipy-2.0.0.tar.gz
  • Upload date:
  • Size: 19.5 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-2.0.0.tar.gz
Algorithm Hash digest
SHA256 aa7b99fe549c2ffc45896fd51a2266c62fb5dbbf68229ed0ab3006da2696f69b
MD5 ac03336d633eb5902119961fdf908e1e
BLAKE2b-256 7b02923fd851140d26916acc8e3086fb9dd1f98b5013562fda6919c62748fd30

See more details on using hashes here.

File details

Details for the file wrapipy-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: wrapipy-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.1 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-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b3a6e87e5f441d886ae4386815a464ee91bfc9d572932d46589b411808f42ea
MD5 268fe03586f9a2fd82d62d4999bf015b
BLAKE2b-256 5d498c97800abca92ea36568bc8fbb29e7ef3503212c168bc802ca396a8fce25

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