Swagger Petstore - OpenAPI 3.0 SDK
The Swagger Petstore - OpenAPI 3.0 SDK for Python provides access to the Swagger Petstore - OpenAPI 3.0 REST APIs from Python applications.
[!TIP] Looking for a specific signature, model, enum, or error type? This SDK ships a generated SDK map -- a lookup index of the SDK's entire Python surface. Consult it before scanning the source tree; details under SDK map.
This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about Swagger at https://swagger.io. In the third iteration of the pet store, we've switched to the design first approach! You can now help us improve the API whether it's by making changes to the definition itself or to the code. That way, with time, we can improve the API in general, and expose some of the new features in OAS3.
Some useful links:
Installation
Install the Python SDK from PyPI, with whichever package manager your project uses:
pip install automated-package-publishing-sdk
uv add automated-package-publishing-sdk
poetry add automated-package-publishing-sdk
Quick Start
Synchronous client
Construct SwaggerPetstoreOpenApi30Client with keyword arguments, and call close() when you are done. Every argument is optional; the full list is in the SDK map.
from swagger_petstore_open_api_3_0 import SwaggerPetstoreOpenApi30Client
client = SwaggerPetstoreOpenApi30Client(petstore_auth="YOUR_API_KEY", api_key="YOUR_API_KEY")
# TODO: call endpoints here -- see api-reference.md
client.close()
Alternatively, scope it -- with SwaggerPetstoreOpenApi30Client(...) as client: closes the pool on exit; see Best Practices.
Client is exported as an alias of SwaggerPetstoreOpenApi30Client, so from swagger_petstore_open_api_3_0 import Client also works.
The SDK accepts every model-typed input in two interchangeable spellings, both type-checked: the typed model, or a plain dict with the same keys -- the OrDict and Model | ModelDict unions in the SDK map. Pick whichever suits the call site: the dict form needs no import, while the model form adds a keyword-checked constructor and editor completion.
Asynchronous client
AsyncSwaggerPetstoreOpenApi30Client mirrors SwaggerPetstoreOpenApi30Client with identical method names, and every endpoint method is a coroutine. It takes the same arguments, with some differences -- for example, the transport argument is custom_async_http_client.
from asyncio import run
from swagger_petstore_open_api_3_0 import AsyncSwaggerPetstoreOpenApi30Client
async def main() -> None:
client = AsyncSwaggerPetstoreOpenApi30Client(petstore_auth="YOUR_API_KEY", api_key="YOUR_API_KEY")
# TODO: call endpoints here, awaiting each -- see api-reference.md
await client.aclose()
run(main())
Alternatively, scope it -- async with AsyncSwaggerPetstoreOpenApi30Client(...) as client: closes the pool on exit. Only the async spelling is aclose, matching httpx; see Best Practices.
AsyncClient is the exported alias. Each client accepts only its own transport argument; passing the other's is a TypeError at runtime and an error under mypy.
Usage
Two generated references cover the SDK; each answers a different question:
| Reference | For |
|---|---|
| API Reference | Usage guidance for a single parsed operation: client.<group>.<operation>(...) returns the typed payload and raises ApiError on any non-2xx, with .error the typed error body, or RawError for a status the operation does not document. |
| Raw API Reference | The same for the raw variant: client.<group>.with_raw_response.<operation>(...) returns ApiResult[T, E] and never raises for an API error. |
Both API references carry every one of the 19 operations, with a sync and an async sample and a parameter table each.
SDK map
This SDK ships a generated SDK map -- sdk-map.md -- a deterministic, lookup-oriented table of contents of the SDK's Python surface, generated by APIMatic alongside this SDK.
Consult the map before scanning or grepping the source: it answers call-level contract questions by lookup, and for anything it does not carry -- model shapes, enum values, an endpoint's route or behavioural prose -- it names the one source file to read. How to read the map itself, including the SDK-wide defaults its rows rely on, is stated at the top of sdk-map.md.
Best Practices
[!TIP] Use a single
SwaggerPetstoreOpenApi30Clientinstance for the lifetime of your application and reuse it across all requests. Each instance owns its own connection pool, so an instance per request forfeits connection reuse and leaks pools that are never closed.
Match the disposal to the client's lifetime: an application-lifetime client is closed once at shutdown with close() / aclose(); where the lifetime fits a block, with SwaggerPetstoreOpenApi30Client() as client: / async with AsyncSwaggerPetstoreOpenApi30Client() as client: releases it automatically. Both are idempotent, but a closed client is not reusable: the next call raises. The client closes whatever transport it holds, including one you supplied via custom_http_client / custom_async_http_client; if you intend to reuse your own transport across clients, don't hand its lifetime to a with block.
License
This SDK is distributed under the MIT License.
Support
Refer to the API reference for detailed information on available operations with code samples.
For further assistance, please contact support at apiteam@swagger.io.
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 automated_package_publishing_sdk-1.0.2.tar.gz.
File metadata
- Download URL: automated_package_publishing_sdk-1.0.2.tar.gz
- Upload date:
- Size: 105.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/2.4.3 CPython/3.13.15 Linux/6.1.158.2-microsoft-standard
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4af0ad6e645dd96ed47b5d366a7dd6b46ae5afbde22c878abe48cb1cba6cb0d
|
|
| MD5 |
ff067dd9aea070ce8b47e9bff62aa659
|
|
| BLAKE2b-256 |
8ee82228ebf091f79142d70e6e40a1175d79582be4f2c90d5a80a45b9413443a
|
File details
Details for the file automated_package_publishing_sdk-1.0.2-py3-none-any.whl.
File metadata
- Download URL: automated_package_publishing_sdk-1.0.2-py3-none-any.whl
- Upload date:
- Size: 145.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/2.4.3 CPython/3.13.15 Linux/6.1.158.2-microsoft-standard
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f6cb50937a9843b4d2a03a0a37852f8a4b77bda83c81b3c65ab398f3a3706ce
|
|
| MD5 |
3a81feede911abc6f068cfbbaa332650
|
|
| BLAKE2b-256 |
0300535d8df5a088880505cd313e50d1895600e1354307e71c6c675ecd0110e8
|