Python Design

Info Icon

OSS Comparison

For a comparison between the Speakeasy Go SDK and some popular open-source generators, see this page.

Speakeasy-generated Python SDKs are designed to be easy to use and easy to debug.

Fully Typed

Speakeasy-generated Python SDKs use modern Python, including exposing type hints to users. Here's an extract of the code Speakeasy generates from the Swagger Petstore OpenAPI schema (opens in a new tab):

@dataclass_json
@dataclass
class Pet:
    name: str = field(metadata={'dataclasses_json': {'letter_case': utils.field_name('name')}})
    photo_urls: list[str] = field(metadata={'dataclasses_json': {'letter_case': utils.field_name('photoUrls')}})
    category: Optional[shared.Category] = field(default=None, metadata={
        'dataclasses_json': {'letter_case': utils.field_name('category')}})
    id: Optional[int] = field(default=None, metadata={'dataclasses_json': {'letter_case': utils.field_name('id')}})
    status: Optional[PetStatusEnum] = field(default=None,
                                            metadata={'dataclasses_json': {'letter_case': utils.field_name('status')}})
    tags: Optional[list[shared.Tag]] = field(default=None,
                                             metadata={'dataclasses_json': {'letter_case': utils.field_name('tags')}})

Using data classes for all generated models allows Speakeasy to append per-field metadata to correctly serialize and deserialize models based on the definitions provided by the OpenAPI document, whether they are serialized as query parameters, path parameters, or request bodies.

If you have any feedback or want to suggest improvements or ask for a new feature, please get in touch in the #client-sdks channel in our public Slack (opens in a new tab).