How environments work
Each exchange library ships with a static class (e.g.BinanceEnvironment, BybitEnvironment) that exposes pre-defined environment objects. These objects contain the base URLs for that environment’s REST and WebSocket endpoints.
When you configure CryptoClients.Net, each exchange defaults to its Live environment. You can override this globally via GlobalExchangeOptions.ApiEnvironments, or per exchange via the exchange-specific options delegate.
Setting an environment per exchange
Use the exchange-specific options parameter onAddCryptoClients to set an environment for a single exchange:
Setting environments via ApiEnvironments
GlobalExchangeOptions.ApiEnvironments is a Dictionary<string, string?> that maps exchange names to environment name strings. This is the recommended approach when loading configuration from appsettings.json, because environment names are plain strings that bind from JSON.
GetEnvironmentByName method (e.g. BinanceEnvironment.GetEnvironmentByName("testnet")). Environment name strings are defined by each exchange library — check the exchange-specific documentation or source for valid values.
Setting environments from appsettings.json
Use theApiEnvironments section inside the CryptoClients config block:
Discovering available environments
UseExchanges.All to get metadata for every supported exchange, including the list of available environments:
ApiEnvironments is a TradeEnvironment with a Name property that matches the string you pass to GetEnvironmentByName or ApiEnvironments in configuration.
Common environment names
The following environment names are available for the most commonly used exchanges:| Exchange | Environment name | Description |
|---|---|---|
| Binance | live | Production API |
| Binance | testnet | Paper trading / testnet |
| Bybit | live | Production API |
| Bybit | eu | European regional endpoint |
| Bybit | testnet | Testnet |
| BitMEX | live | Production API |
| BitMEX | testnet | Testnet |
| Kraken | live | Production API |
| OKX | live | Production API |
| OKX | aws | AWS endpoint |
Not every exchange provides a testnet. Check the exchange-specific library
documentation to confirm which environments are available before configuring
one.
Example: switching between live and testnet
A common pattern is to read the environment from application configuration so you can switch between live and testnet without code changes:"testnet" to "live" (and update your credentials) to point at the production API.