Skip to main content

A Python client for OpenAPI specifications using httpx

Project description

OpenAPI Client for Python

A Python implementation inspired by openapi-client-axios that provides a dynamic client for OpenAPI specifications. This implementation uses httpx for HTTP requests and Python's metaprogramming capabilities to dynamically generate a client.

Installation

pip install openapi-httpx-client

Usage

from openapiclient import OpenAPIClient
import asyncio

async def main():
    # Initialize the client with the OpenAPI definition
    api = OpenAPIClient(definition="https://petstore3.swagger.io/api/v3/openapi.json")

    try:
        # Initialize and get the dynamic client
        client = await api.init()

        # Call an operation using the generated method
        response = await client.getPetById(petId=1)

        # Print the response
        print(f"Status code: {response['status']}")
        print(f"Pet data: {response['data']}")
    finally:
        # Close the HTTP session
        await api.close()

if __name__ == "__main__":
    asyncio.run(main())

Features

  • Dynamic client generation using Python metaprogramming
  • Supports OpenAPI 3.0 and 3.1
  • Supports JSON and YAML specification formats
  • Supports specification loading from URL, file, or dictionary
  • Asynchronous API using httpx
  • Response format similar to axios (data, status, headers, config)

Author

lloydzhou (2025-02-27)

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

openapi_httpx_client-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

openapi_httpx_client-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file openapi_httpx_client-0.1.1.tar.gz.

File metadata

  • Download URL: openapi_httpx_client-0.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.2

File hashes

Hashes for openapi_httpx_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 67a3c5c57b5c356e2878de14334cb878a4a3af41da0b209a05edca49c7bc230f
MD5 60aba30ddf56f1b4b9341ec9bcc1b786
BLAKE2b-256 b5a1fa47f7357122c74a3a64cf127d305ff902fd7b4e505e8f63f2c2fbf89f3c

See more details on using hashes here.

File details

Details for the file openapi_httpx_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for openapi_httpx_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f1e7b8e31945125a708dd576e23bdbf1de5b265acdf28553b77f3d3f8197d31
MD5 97c2f4a5ef3beb1660d1ff80df0fa053
BLAKE2b-256 1f90875321fe92b2b4ccc61a84d1e7f407a56af4d28751ff39d9f6e92fa8a8ff

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