Speakeasy API Client SDK for Python
Project description
speakeasy-client-sdk-python
SDK Installation
pip install speakeasy-client-sdk-python
SDK Example Usage
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
- validate_api_key - Validate the current api key.
apis
- delete_api - Delete an Api.
- generate_open_api_spec - Generate an OpenAPI specification for a particular Api.
- generate_postman_collection - Generate a Postman collection for a particular Api.
- get_all_api_versions - Get all Api versions for a particular ApiEndpoint.
- get_apis - Get a list of Apis for a given workspace
- upsert_api - Upsert an Api
api_endpoints
- delete_api_endpoint - Delete an ApiEndpoint.
- find_api_endpoint - Find an ApiEndpoint via its displayName.
- generate_open_api_spec_for_api_endpoint - Generate an OpenAPI specification for a particular ApiEndpoint.
- generate_postman_collection_for_api_endpoint - Generate a Postman collection for a particular ApiEndpoint.
- get_all_api_endpoints - Get all Api endpoints for a particular apiID.
- get_all_for_version_api_endpoints - Get all ApiEndpoints for a particular apiID and versionID.
- get_api_endpoint - Get an ApiEndpoint.
- upsert_api_endpoint - Upsert an ApiEndpoint.
metadata
- delete_version_metadata - Delete metadata for a particular apiID and versionID.
- get_version_metadata - Get all metadata for a particular apiID and versionID.
- insert_version_metadata - Insert metadata for a particular apiID and versionID.
schemas
- delete_schema - Delete a particular schema revision for an Api.
- download_schema - Download the latest schema for a particular apiID.
- download_schema_revision - Download a particular schema revision for an Api.
- get_schema - Get information about the latest schema.
- get_schema_diff - Get a diff of two schema revisions for an Api.
- get_schema_revision - Get information about a particular schema revision for an Api.
- get_schemas - Get information about all schemas associated with a particular apiID.
- register_schema - Register a schema.
requests
- generate_request_postman_collection - Generate a Postman collection for a particular request.
- get_request_from_event_log - Get information about a particular request.
- query_event_log - Query the event log to retrieve a list of requests.
plugins
- get_plugins - Get all plugins for the current workspace.
- run_plugin - Run a plugin
- upsert_plugin - Upsert a plugin
embeds
- get_embed_access_token - Get an embed access token for the current workspace.
- get_valid_embed_access_tokens - Get all valid embed access tokens for the current workspace.
- revoke_embed_access_token - Revoke an embed access EmbedToken.
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 |
For 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
Built Distribution
Hashes for speakeasy-client-sdk-python-3.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26fd960bfb0ca030a4da3bafc233745e4ad7980bb80f1f800acd3a58c9f6439c |
|
MD5 | 807029e9e339541d4298300728b4b93a |
|
BLAKE2b-256 | 2f0476792d3781aede344e2a6cbafe0c71b6271c05dc0dc6542a29745ceb5d98 |
Hashes for speakeasy_client_sdk_python-3.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aac4dd6478abee8a2fc5fde7eef1d681fcd2959984072016f9a7e7c3e7f593c9 |
|
MD5 | 99e710fb315ec2ddc8942cedfd63cdd1 |
|
BLAKE2b-256 | c5594c2b846c9191845f689a665ab015390e92ec585cbe7d16056be4eebfd60d |