Skip to main content

Create a Credential

Store your exchange API keys securely in Cadenza. Once created, the credential can be used to connect one or more trading accounts.

Before You Begin

  1. Generate API keys on your exchange (see Supported Venues for setup instructions)
  2. Note the required fields for your exchange
  3. Ensure API keys have appropriate permissions (trade, read balances)

Create Credential

response = credential_api.create_trading_account_credential(
cadenza_client.CreateTradingAccountCredentialRequest(
venue=cadenza_client.Venue.BINANCE,
credential_type=cadenza_client.CredentialType.EXCHANGE,
api_key="your-api-key",
api_secret="your-api-secret",
nickname="My Binance API" # optional
)
)

credential = response.data
print(f"Credential ID: {credential.credential_id}")
print(f"Status: {credential.status}") # PENDING

Request Parameters

ParameterTypeRequiredDescription
venueVenueYesExchange venue (BINANCE, OKX, BYBIT, etc.)
credentialTypeCredentialTypeYesType of credential (EXCHANGE, BROKER)
apiKeystringYesAPI key from your exchange
apiSecretstringYesAPI secret from your exchange
apiPassphrasestringConditionalRequired for OKX and some other exchanges
nicknamestringNoDisplay name for the credential

Response

The response contains the created Credential object:

{
"data": {
"credentialId": "550e8400-e29b-41d4-a716-446655440000",
"venue": "BINANCE",
"credentialType": "EXCHANGE",
"nickname": "My Binance API",
"status": "PENDING",
"identities": [],
"createdAt": 1704067200000,
"updatedAt": 1704067200000
},
"success": true,
"errno": 0,
"error": null
}

Exchange-Specific Examples

Binance

response = credential_api.create_trading_account_credential(
cadenza_client.CreateTradingAccountCredentialRequest(
venue=cadenza_client.Venue.BINANCE,
credential_type=cadenza_client.CredentialType.EXCHANGE,
api_key="your-binance-api-key",
api_secret="your-binance-api-secret"
)
)

OKX (with passphrase)

response = credential_api.create_trading_account_credential(
cadenza_client.CreateTradingAccountCredentialRequest(
venue=cadenza_client.Venue.OKX,
credential_type=cadenza_client.CredentialType.EXCHANGE,
api_key="your-okx-api-key",
api_secret="your-okx-api-secret",
api_passphrase="your-okx-passphrase" # Required for OKX
)
)

Error Handling

Error CodeDescription
400Invalid request parameters
401Authentication required
409Credential with same API key already exists
422Invalid API key format
from cadenza_client.rest import ApiException

try:
response = credential_api.create_trading_account_credential(request)
except ApiException as e:
print(f"Error {e.status}: {e.body}")

Next Steps

After creating a credential, you should verify it to:

  • Confirm the API keys are valid
  • Discover available trading accounts on the exchange