Skip to main content

Client for Python Pydantic Responses API

Project description

python-pydantic-responses-python-sdk

A simple API based on python pydantic responses.

PyPI README.md More Info

Table of Contents

Requirements

Python >=3.7

Installing

pip install python-pydantic-responses-python-sdk==1.0.0

Getting Started

from pprint import pprint
from python_pydantic import PythonPydanticResponses, ApiException

pythonpydanticresponses = PythonPydanticResponses(
    api_key="YOUR_API_KEY",
)

try:
    # Fetches a JSON value based on input parameter
    fetch_response = pythonpydanticresponses.test.fetch(
        input_parameter="inputParameter_example",
    )
    print(fetch_response)
except ApiException as e:
    print("Exception when calling TestApi.fetch: %s\n" % e)
    pprint(e.body)
    if e.status == 400:
        pprint(e.body["error"])
    if e.status == 500:
        pprint(e.body["error"])
    pprint(e.headers)
    pprint(e.status)
    pprint(e.reason)
    pprint(e.round_trip_time)

Async

async support is available by prepending a to any method.

import asyncio
from pprint import pprint
from python_pydantic import PythonPydanticResponses, ApiException

pythonpydanticresponses = PythonPydanticResponses(
    api_key="YOUR_API_KEY",
)


async def main():
    try:
        # Fetches a JSON value based on input parameter
        fetch_response = await pythonpydanticresponses.test.afetch(
            input_parameter="inputParameter_example",
        )
        print(fetch_response)
    except ApiException as e:
        print("Exception when calling TestApi.fetch: %s\n" % e)
        pprint(e.body)
        if e.status == 400:
            pprint(e.body["error"])
        if e.status == 500:
            pprint(e.body["error"])
        pprint(e.headers)
        pprint(e.status)
        pprint(e.reason)
        pprint(e.round_trip_time)


asyncio.run(main())

Raw HTTP Response

To access raw HTTP response values, use the .raw namespace.

from pprint import pprint
from python_pydantic import PythonPydanticResponses, ApiException

pythonpydanticresponses = PythonPydanticResponses(
    api_key="YOUR_API_KEY",
)

try:
    # Fetches a JSON value based on input parameter
    fetch_response = pythonpydanticresponses.test.raw.fetch(
        input_parameter="inputParameter_example",
    )
    pprint(fetch_response.body)
    pprint(fetch_response.body["property_a"])
    pprint(fetch_response.body["property_b"])
    pprint(fetch_response.body["property_c"])
    pprint(fetch_response.headers)
    pprint(fetch_response.status)
    pprint(fetch_response.round_trip_time)
except ApiException as e:
    print("Exception when calling TestApi.fetch: %s\n" % e)
    pprint(e.body)
    if e.status == 400:
        pprint(e.body["error"])
    if e.status == 500:
        pprint(e.body["error"])
    pprint(e.headers)
    pprint(e.status)
    pprint(e.reason)
    pprint(e.round_trip_time)

Reference

pythonpydanticresponses.test.fetch

Provide an input parameter to receive a JSON value with properties.

🛠️ Usage

fetch_response = pythonpydanticresponses.test.fetch(
    input_parameter="inputParameter_example",
)

⚙️ Parameters

input_parameter: str

The input parameter to process.

🔄 Return

TestFetchResponse

🌐 Endpoint

/simple-endpoint get

🔙 Back to Table of Contents


pythonpydanticresponses.test.reserved_word

Reserved word in Python

🛠️ Usage

reserved_word_response = pythonpydanticresponses.test.reserved_word()

🔄 Return

TestReservedWord

🌐 Endpoint

/reserved-word get

🔙 Back to Table of Contents


Author

This Python package is automatically generated by Konfig

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

Built Distribution

Supported by

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