ExchangeCredentials class to hold typed API credentials for every exchange you want to authenticate with. Each exchange has its own credential type — most require a key and secret, while some also require a passphrase.
Basic usage
Set credentials globally inAddCryptoClients:
Some exchanges require a passphrase (also called a memo or API password) in
addition to a key and secret. These exchanges include Kucoin, OKX,
Bitget, BitMart, BloFin, and DeepCoin. Their credential
constructors accept a third string parameter for the passphrase.
Setting credentials at runtime
You can update credentials on an already-constructed client usingSetApiCredentials:
Dynamic credentials
DynamicCredentials lets you build credentials from generic string parameters when you don’t know at compile time which exchange you’re targeting. This is useful for multi-user scenarios or configuration-driven setups.
DynamicCredentials properties
The trading mode these credentials are for (
Spot, PerpetualLinear,
PerpetualInverse, etc.). Some exchanges (e.g. Kraken) use different
credentials for spot vs futures.The API key.
First parameter — generally the API secret or private key.
Second parameter — generally the passphrase.
Third parameter, for exchanges that require additional values.
Discovering what parameters an exchange needs
UseExchangeCredentials.GetDynamicCredentialInfo to find out at runtime which parameters a given exchange requires:
DynamicCredentialInfo contains:
The exchange name.
Description of what the
Key value should be (e.g. "API key").Whether
Param1 is required for this exchange.Description of what
Param1 should contain (e.g. "API secret").Whether
Param2 is required for this exchange.Description of what
Param2 should contain (e.g. "Passphrase").Whether
Param3 is required for this exchange.Description of what
Param3 should contain.Building ExchangeCredentials dynamically
Use the static factory methods onExchangeCredentials when you need to construct credentials from a dictionary or from a DynamicCredentials object.
ExchangeCredentials.CreateFrom
Creates anExchangeCredentials instance from a dictionary of exchange names to typed credential objects:
ExchangeCredentials.CreateCredentialsForExchange
Converts aDynamicCredentials object into the correct typed ApiCredentials for a named exchange: