import kalshi_python
from kalshi_python.models.get_events_response import GetEventsResponse
from kalshi_python.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.elections.kalshi.com/trade-api/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = kalshi_python.Configuration(
host = "https://api.elections.kalshi.com/trade-api/v2"
)
# Read private key from file
with open('path/to/private_key.pem', 'r') as f:
private_key = f.read()
# Configure API key authentication
configuration.api_key_id = "your-api-key-id"
configuration.private_key_pem = private_key
# Initialize the Kalshi client
client = kalshi_python.KalshiClient(configuration)
limit = 100 # int | Number of results per page. Defaults to 100. Maximum value is 200. (optional) (default to 100)
cursor = 'cursor_example' # str | Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page. (optional)
with_nested_markets = False # bool | If true, markets are included within the event object. If false (default), markets are returned as a separate top-level field in the response. (optional) (default to False)
status = 'status_example' # str | Filter by status. Possible values depend on the endpoint. (optional)
series_ticker = 'series_ticker_example' # str | Filter by series ticker (optional)
min_close_ts = 56 # int | Filter items that close after this Unix timestamp (optional)
try:
# Get Events
api_response = client.get_events(limit=limit, cursor=cursor, with_nested_markets=with_nested_markets, status=status, series_ticker=series_ticker, min_close_ts=min_close_ts)
print("The response of EventsApi->get_events:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling EventsApi->get_events: %s\n" % e)