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="<YOUR_API_KEY_HERE>",
    ),
)

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

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 4x-5xx /

Example

import speakeasy
from speakeasy.models import shared

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


res = None
try:
    res = s.validate_api_key()
except errors.SDKError as e:
    print(e)  # handle exception
    raise(e)

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="<YOUR_API_KEY_HERE>",
    ),
)


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="<YOUR_API_KEY_HERE>",
    ),
)


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 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="<YOUR_API_KEY_HERE>",
    ),
)


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

This version

3.3.2

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.3.2.tar.gz (28.3 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.3.2-py3-none-any.whl (65.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for speakeasy-client-sdk-python-3.3.2.tar.gz
Algorithm Hash digest
SHA256 cee58eea50621bfeb98a4676aefa827a3c8f1952aac47e03cb503e5d854ee0e4
MD5 637a6ba7dec65be3b492a10c1deb0867
BLAKE2b-256 00592e9a6b53449ab37a4703ae114cf623c4945ab5b9177e15d4750b7a229dc4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for speakeasy_client_sdk_python-3.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4b464e6966fef44f11b82ec15efdd6c943345720001387f3ab9acc2cb0233fc0
MD5 8606a36aeb7f3631b652f39841fd2ca5
BLAKE2b-256 ae6f3dc568f5e80e99df6e1d7f54fd7d2da70ae5cdfc0a19903f74968ca7b0d6

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