kalshi-cpp 0.6.2
C++23 client for Kalshi's Predictions API
Loading...
Searching...
No Matches
kalshi::Signer Class Reference

Signs Kalshi requests with an API key. More...

#include <kalshi/signer.hpp>

Public Member Functions

Result< AuthHeaders > sign (std::string_view method, std::string_view path) const
 Signs a request at the current time.
 
Result< AuthHeaders > sign_with_timestamp (std::string_view method, std::string_view path, std::int64_t timestamp_ms) const
 Signs a request at a fixed time. Useful for tests.
 
std::string_view api_key_id () const noexcept
 
KeyType key_type () const noexcept
 

Static Public Member Functions

static Result< Signer > from_pem (std::string_view api_key_id, std::string_view pem_key)
 Loads an unencrypted PEM private key (PKCS#1 or PKCS#8).
 
static Result< Signer > from_pem_file (std::string_view api_key_id, std::string_view file_path)
 Reads a PEM private key from a file. See from_pem().
 

Detailed Description

Signs Kalshi requests with an API key.

The signed message is timestamp + METHOD + path, where the path starts at /trade-api/... and excludes the query string. The algorithm follows the key: RSA keys use RSA-PSS/SHA-256, Ed25519 keys use Ed25519.

Copies share the same immutable key, and signing is thread-safe.

Member Function Documentation

◆ from_pem()

static Result< Signer > kalshi::Signer::from_pem ( std::string_view  api_key_id,
std::string_view  pem_key 
)
static

Loads an unencrypted PEM private key (PKCS#1 or PKCS#8).

Encrypted keys and algorithms other than RSA and Ed25519 are rejected.

◆ from_pem_file()

static Result< Signer > kalshi::Signer::from_pem_file ( std::string_view  api_key_id,
std::string_view  file_path 
)
static

Reads a PEM private key from a file. See from_pem().

◆ sign()

Result< AuthHeaders > kalshi::Signer::sign ( std::string_view  method,
std::string_view  path 
) const

Signs a request at the current time.

◆ sign_with_timestamp()

Result< AuthHeaders > kalshi::Signer::sign_with_timestamp ( std::string_view  method,
std::string_view  path,
std::int64_t  timestamp_ms 
) const

Signs a request at a fixed time. Useful for tests.

◆ api_key_id()

std::string_view kalshi::Signer::api_key_id ( ) const
noexcept

◆ key_type()

KeyType kalshi::Signer::key_type ( ) const
noexcept

The documentation for this class was generated from the following file: