API and SDK reference
Client SDKs
We offer native client SDKs in the following languages. Select a language to view documentation and usage examples for that language.
Installation
_10pip install git+<UNSET>.git
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:
_10import sdk_10import requests_10_10http_client = requests.Session()_10http_client.headers.update({'x-custom-header': 'someValue'})_10s = sdk.SDK(client: http_client)
Security Options
Per-Client Security Schemes
This SDK supports the following security scheme globally:
To authenticate with the API the api_key
parameter must be set when initializing the SDK client instance. For example:
_14import sdk_14from sdk.models import operations_14_14s = sdk.SDK(_14 api_key="<YOUR_API_KEY_HERE>",_14)_14_14req = operations.AuthenticateRequestBody()_14_14res = s.authentication.authenticate(req)_14_14if res.object is not None:_14 # handle response_14 pass
Errors
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.
Example
_22import sdk_22from sdk.models import operations_22_22s = sdk.SDK(_22 api_key="<YOUR_API_KEY_HERE>",_22)_22_22req = operations.AuthenticateRequestBody()_22_22res = None_22try:_22 res = s.authentication.authenticate(req)_22except errors.APIError as e:_22 print(e) # handle exception_22 raise(e)_22except errors.SDKError as e:_22 print(e) # handle exception_22 raise(e)_22_22if res.object is not None:_22 # handle response_22 pass
Server Options
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:
Example
_15import sdk_15from sdk.models import operations_15_15s = sdk.SDK(_15 server="customer",_15 api_key="<YOUR_API_KEY_HERE>",_15)_15_15req = operations.AuthenticateRequestBody()_15_15res = s.authentication.authenticate(req)_15_15if res.object is not None:_15 # handle response_15 pass
Variables
Some of the server options above contain variables. If you want to set the values of those variables, the following optional parameters are available when initializing the SDK client instance:
organization: str
environment: models.ServerEnvironment
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:
_15import sdk_15from sdk.models import operations_15_15s = sdk.SDK(_15 server_url="https://speakeasy.bar",_15 api_key="<YOUR_API_KEY_HERE>",_15)_15_15req = operations.AuthenticateRequestBody()_15_15res = s.authentication.authenticate(req)_15_15if res.object is not None:_15 # handle response_15 pass
Authentication
The authentication endpoints.
Available Operations
- Authenticate - Authenticate with the API by providing a username and password.
Authentication
Authenticate
Authenticate with the API by providing a username and password.
Parameters
request
operations.AuthenticateRequestBody
The request object to use for the request.
Show child properties
username
Optional[str]
password
Optional[str]
Response
operations.AuthenticateResponse
Hide child properties
content_type
str
HTTP response content type for this operation
status_code
int
HTTP response status code for this operation
raw_response
requests.Response
Raw HTTP response; suitable for custom response parsing
object
Optional[operations.AuthenticateResponseBody]
The api key to use for authenticated endpoints.
Show child properties
error
Optional[components.Error]
An unknown error occurred interacting with the API.
Show child properties
Drinks
The drinks endpoints.
Available Operations
- List Drinks - Get a list of drinks.
- Get Drink - Get a drink.
Drinks
List Drinks
Get a list of drinks, if authenticated this will include stock levels and product codes otherwise it will only include public information.
Parameters
drink_type
Optional[components.DrinkType]
The type of drink to filter by. If not provided all drinks will be returned.
Show child properties
Name | Value |
---|---|
COCKTAIL | cocktail |
NON_ALCOHOLIC | non-alcoholic |
BEER | beer |
WINE | wine |
SPIRIT | spirit |
OTHER | other |
Response
operations.ListDrinksResponse
Hide child properties
content_type
str
HTTP response content type for this operation
status_code
int
HTTP response status code for this operation
raw_response
requests.Response
Raw HTTP response; suitable for custom response parsing
classes
List[components.Drink]
A list of drinks.
Show child properties
error
Optional[components.Error]
An unknown error occurred interacting with the API.
Show child properties
Drinks
Get Drink
Get a drink by name, if authenticated this will include stock levels and product codes otherwise it will only include public information.
Parameters
name
str
Response
operations.GetDrinkResponse
Hide child properties
content_type
str
HTTP response content type for this operation
status_code
int
HTTP response status code for this operation
raw_response
requests.Response
Raw HTTP response; suitable for custom response parsing
drink
Optional[components.Drink]
A drink.
Show child properties
error
Optional[components.Error]
An unknown error occurred interacting with the API.
Show child properties
Ingredients
The ingredients endpoints.
Available Operations
- List Ingredients - Get a list of ingredients.
Ingredients
List Ingredients
Get a list of ingredients, if authenticated this will include stock levels and product codes otherwise it will only include public information.
Parameters
ingredients
List[*str*]
A list of ingredients to filter by. If not provided all ingredients will be returned.
Response
operations.ListIngredientsResponse
Hide child properties
content_type
str
HTTP response content type for this operation
status_code
int
HTTP response status code for this operation
raw_response
requests.Response
Raw HTTP response; suitable for custom response parsing
classes
List[components.Ingredient]
A list of ingredients.
Show child properties
error
Optional[components.Error]
An unknown error occurred interacting with the API.
Show child properties
Orders
The orders endpoints.
Available Operations
- Create Order - Create an order.
Orders
Create Order
Create an order for a drink.
Parameters
request_body
List[components.OrderInput]
Show child properties
type
components.OrderType
The type of order.
Show child properties
product_code
str
The product code of the drink or ingredient.
Example: AC-A2DF3
quantity
int
The number of units of the drink or ingredient to order.
callback_url
Optional[str]
The url to call when the order is updated.
Response
operations.CreateOrderResponse
Hide child properties
content_type
str
HTTP response content type for this operation
status_code
int
HTTP response status code for this operation
raw_response
requests.Response
Raw HTTP response; suitable for custom response parsing
order
Optional[components.Order]
The order was created successfully.
Show child properties
error
Optional[components.Error]
An unknown error occurred interacting with the API.
Show child properties
Config
Available Operations
- Subscribe To Webhooks - Subscribe to webhooks.
Config
Subscribe To Webhooks
Subscribe to webhooks.
Parameters
request
List[operations.RequestBody]
The request object to use for the request.
Show child properties
url
Optional[str]
webhook
Optional[operations.Webhook]
Show child properties
Response
operations.SubscribeToWebhooksResponse
Hide child properties
content_type
str
HTTP response content type for this operation
status_code
int
HTTP response status code for this operation
raw_response
requests.Response
Raw HTTP response; suitable for custom response parsing
error
Optional[components.Error]
An unknown error occurred interacting with the API.