Skip to content

Crypto API Reference

CryptoClient

pyhood.crypto.client.CryptoClient

Robinhood Crypto Trading API v2 client.

Handles ED25519 authentication, rate limiting, and pagination.

Usage

client = CryptoClient(api_key, private_key_base64) account = client.get_account() quote = client.get_best_bid_ask("BTC-USD")

__init__(api_key, private_key_base64, timeout=30.0)

Initialize crypto client with API credentials.

Parameters:

Name Type Description Default
api_key str

Robinhood Crypto API key

required
private_key_base64 str

Base64-encoded ED25519 private key

required
timeout float

Request timeout in seconds

30.0

make_request(method, path, body='', params=None, retries=3)

Make an authenticated request to the Crypto API.

Parameters:

Name Type Description Default
method str

HTTP method (GET, POST, etc.)

required
path str

API path (e.g., '/api/v2/crypto/trading/accounts/')

required
body str

Request body as JSON string

''
params dict[str, Any] | None

Query parameters

None
retries int

Number of retries on rate limit/server errors

3

Returns:

Type Description
dict[str, Any]

Parsed JSON response

Raises:

Type Description
RateLimitError

Rate limited and no retries left

AuthError

Authentication failed

APIError

API returned an error

get_account()

Get crypto trading account information.

Returns:

Type Description
CryptoAccount

CryptoAccount with account details

get_trading_pairs(*symbols)

Get trading pair information for crypto symbols.

Parameters:

Name Type Description Default
*symbols str

Crypto symbols (e.g., 'BTC-USD', 'ETH-USD')

()

Returns:

Type Description
list[TradingPair]

List of TradingPair objects

get_best_bid_ask(*symbols)

Get best bid/ask prices for crypto symbols.

Parameters:

Name Type Description Default
*symbols str

Crypto symbols (e.g., 'BTC-USD', 'ETH-USD')

()

Returns:

Type Description
list[CryptoQuote]

List of CryptoQuote objects

get_estimated_price(symbol, side, quantity)

Get estimated price for a crypto trade.

Parameters:

Name Type Description Default
symbol str

Crypto symbol (e.g., 'BTC-USD')

required
side str

'buy' or 'sell'

required
quantity float

Trade quantity

required

Returns:

Type Description
EstimatedPrice

EstimatedPrice object

get_historicals(symbol, interval='hour', span='week')

Get historical OHLCV data for a crypto asset.

Parameters:

Name Type Description Default
symbol str

Crypto symbol (e.g., 'BTC-USD').

required
interval str

Candle interval. One of '15second', 'minute', '5minute', '10minute', 'hour', 'day', 'week'. Default: 'hour'.

'hour'
span str

Time range. One of 'hour', 'day', 'week', 'month', '3month', 'year', '5year'. Default: 'week'.

'week'

Returns:

Type Description
list[CryptoCandle]

List of CryptoCandle dataclasses with OHLCV data.

get_holdings(account_number, *asset_codes)

Get crypto holdings for account.

Parameters:

Name Type Description Default
account_number str

Crypto account number

required
*asset_codes str

Asset codes to filter by (e.g., 'BTC', 'ETH')

()

Returns:

Type Description
list[CryptoHolding]

List of CryptoHolding objects

place_order(account_number, side, order_type, symbol, order_config)

Place a crypto order.

Parameters:

Name Type Description Default
account_number str

Crypto account number

required
side str

'buy' or 'sell'

required
order_type str

'market' or 'limit'

required
symbol str

Crypto symbol (e.g., 'BTC-USD')

required
order_config dict[str, Any]

Order-specific configuration

required

Returns:

Type Description
CryptoOrder

CryptoOrder object

get_order(account_number, order_id)

Get a specific crypto order.

Parameters:

Name Type Description Default
account_number str

Crypto account number

required
order_id str

Order ID

required

Returns:

Type Description
CryptoOrder

CryptoOrder object

get_orders(account_number)

Get all crypto orders for account.

Parameters:

Name Type Description Default
account_number str

Crypto account number

required

Returns:

Type Description
list[CryptoOrder]

List of CryptoOrder objects

cancel_order(order_id)

Cancel a crypto order.

Parameters:

Name Type Description Default
order_id str

Order ID to cancel

required

Returns:

Type Description
dict[str, Any]

API response data

Authentication

pyhood.crypto.auth.generate_keypair()

Generate an ED25519 keypair for crypto API authentication.

Returns:

Type Description
tuple[str, str]

Tuple of (private_key_base64, public_key_base64)

pyhood.crypto.auth.sign_request(api_key, private_key_base64, method, path, body='')

Sign a Crypto API request using ED25519.

Parameters:

Name Type Description Default
api_key str

Robinhood Crypto API key

required
private_key_base64 str

Base64-encoded private key

required
method str

HTTP method (GET, POST, etc.)

required
path str

URL path (e.g., '/api/v2/crypto/trading/accounts/')

required
body str

Request body JSON string (empty for GET requests)

''

Returns:

Type Description
tuple[str, str, str]

Tuple of (api_key_header, signature_header, timestamp_header)

Raises:

Type Description
ValueError

If private key is invalid

Models

pyhood.crypto.models

Crypto data models — typed dataclasses for Robinhood Crypto API responses.

CryptoQuote dataclass

Crypto quote data with best bid/ask.

CryptoHolding dataclass

Crypto asset holding information.

CryptoAccount dataclass

Crypto trading account information.

TradingPair dataclass

Trading pair configuration and limits.

EstimatedPrice dataclass

Estimated price for a crypto trade.

CryptoCandle dataclass

Single OHLCV price candle for a crypto asset.

CryptoOrder dataclass

Crypto order information.