Skip to main content

Speakeasy API Client SDK for Python

Project description

speakeasy-client-sdk-python

SDK Installation

pip install speakeasy-client-sdk-python

SDK Example Usage

Example

import speakeasy
from speakeasy.models import operations, shared

s = speakeasy.Speakeasy(
    security=shared.Security(
        api_key="",
    ),
)

req = operations.GetApisRequest(
    metadata={
        "key": [
            'string',
        ],
    },
    op=operations.QueryParamOp(
        and_=False,
    ),
)

res = s.apis.get_apis(req)

if res.classes is not None:
    # handle response
    pass

Available Resources and Operations

Speakeasy SDK

apis

api_endpoints

metadata

schemas

requests

plugins

embeds

Pagination

Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the returned response object will have a Next method that can be called to pull down the next group of results. If the return value of Next is None, then there are no more pages to be fetched.

Here's an example of one such pagination call:

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.

Error Object Status Code Content Type
errors.SDKError 400-600 /

Example

import speakeasy
from speakeasy.models import shared

s = speakeasy.Speakeasy(
    security=shared.Security(
        api_key="",
    ),
)


res = None
try:
    res = s.validate_api_key()

except (errors.SDKError) as e:
    print(e) # handle exception


if res.status_code == 200:
    # handle response
    pass

Server Selection

Select Server by Name

You can override the default server globally by passing a server name to the server: str optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:

Name Server Variables
prod https://api.prod.speakeasyapi.dev None

Example

import speakeasy
from speakeasy.models import shared

s = speakeasy.Speakeasy(
    server="prod",
    security=shared.Security(
        api_key="",
    ),
)


res = s.validate_api_key()

if res.status_code == 200:
    # handle response
    pass

Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:

import speakeasy
from speakeasy.models import shared

s = speakeasy.Speakeasy(
    server_url="https://api.prod.speakeasyapi.dev",
    security=shared.Security(
        api_key="",
    ),
)


res = s.validate_api_key()

if res.status_code == 200:
    # handle response
    pass

Custom HTTP Client

The Python SDK makes API calls using the (requests)[https://pypi.org/project/requests/] HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom requests.Session object.

For example, you could specify a header for every request that this sdk makes as follows:

import speakeasy
import requests

http_client = requests.Session()
http_client.headers.update({'x-custom-header': 'someValue'})
s = speakeasy.Speakeasy(client: http_client)

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
api_key apiKey API key

You can set the security parameters through the security optional parameter when initializing the SDK client instance. For example:

import speakeasy
from speakeasy.models import shared

s = speakeasy.Speakeasy(
    security=shared.Security(
        api_key="",
    ),
)


res = s.validate_api_key()

if res.status_code == 200:
    # handle response
    pass

SDK Generated by Speakeasy

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

speakeasy-client-sdk-python-3.1.3.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

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

speakeasy_client_sdk_python-3.1.3-py3-none-any.whl (65.2 kB view details)

Uploaded Python 3

File details

Details for the file speakeasy-client-sdk-python-3.1.3.tar.gz.

File metadata

File hashes

Hashes for speakeasy-client-sdk-python-3.1.3.tar.gz
Algorithm Hash digest
SHA256 31c4199a7ba408cc541cc798e5cc0a13ec6475edb760b348025ab732db970b31
MD5 aa8e858a7b654b3f2d1a116878568274
BLAKE2b-256 1f6123f56a0ace13aba89b670e71a3dab19a04d96a77d89bafcd187a9240d051

See more details on using hashes here.

File details

Details for the file speakeasy_client_sdk_python-3.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for speakeasy_client_sdk_python-3.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0f4ff316f818da0d13dd0be94d1b91763a742bb6d728b934beb5de5da19ced14
MD5 41b8bc65c9015a76b993a2e28ea9fa85
BLAKE2b-256 3cf2572b52273a9bd8f06b0942f7f3e43d0d70d937aef0c00075b069dc636ef8

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