↓ Skip to main content
All methods

stakepd.kalshi_data.load_private_key

Function
Signature
kd.load_private_key(private_key=None, private_key_path=None, password=None)

Load an RSA or Ed25519 PEM private key.

You don’t normally need this: KalshiClient loads the key for you. It’s useful together with KalshiAuth for calling endpoints the wrapper doesn’t cover.

Parameters

private_key:str or bytes, optional
The PEM text. Use this or private_key_path.
private_key_path:str or os.PathLike, optional
Path to the .pem file.
password:bytes, optional
Password, if the key file is encrypted.

Returns

private key
The loaded RSA or Ed25519 key (a cryptography key object).

Raises

KalshiAuthError
If the key can’t be loaded.

See also

KalshiAuth
A requests authentication handler that adds Kalshi’s signature headers.
KalshiClient
Create a client for the Kalshi Trade API v2.

Examples
#

Example:

from stakepd import kalshi_data as kd

key = kd.load_private_key(private_key_path="~/.kalshi/key.pem")

This method is also covered, alongside the rest of the module, in the overview guide.