Skip to content

Paradex Python SDK

Warning

Experimental SDK, library API is subject to change

paradex_py.paradex.Paradex

Paradex class to interact with Paradex REST API.

Parameters:

Name Type Description Default
env Environment

Environment

required
l1_address str

L1 address. Defaults to None.

None
l1_private_key str

L1 private key. Defaults to None.

None
l2_private_key str

L2 private key. Defaults to None.

None
logger Logger

Logger. Defaults to None.

None
ws_timeout int

WebSocket read timeout in seconds. Defaults to None (uses default).

None
http_client HttpClient

Custom HTTP client for injection. Defaults to None.

None
api_base_url str

Custom API base URL override. Defaults to None.

None
default_timeout float

Default HTTP request timeout in seconds. Defaults to None.

None
retry_strategy RetryStrategy

Custom retry/backoff strategy. Defaults to None.

None
request_hook RequestHook

Hook for request/response observability. Defaults to None.

None
auto_start_ws_reader bool

Whether to automatically start WS message reader. Defaults to True.

True
ws_connector WebSocketConnector

Custom WebSocket connector for injection. Defaults to None.

None
ws_url_override str

Custom WebSocket URL override. Defaults to None.

None
ws_reader_sleep_on_error float

WebSocket reader sleep duration after errors. Defaults to 1.0.

1.0
ws_reader_sleep_on_no_connection float

WebSocket reader sleep when no connection. Defaults to 1.0.

1.0
validate_ws_messages bool

Enable JSON-RPC message validation. Defaults to False.

False
ping_interval float

WebSocket ping interval in seconds. Defaults to None.

None
disable_reconnect bool

Disable automatic WebSocket reconnection. Defaults to False.

False
auto_auth bool

Whether to automatically handle onboarding/auth. Defaults to True.

True
auth_provider AuthProvider

Custom authentication provider. Defaults to None.

None
signer Signer

Custom order signer for submit/modify/batch operations. Defaults to None.

None

Examples:

>>> from paradex_py import Paradex
>>> from paradex_py.environment import Environment
>>> paradex = Paradex(env=Environment.TESTNET)
>>> # With custom timeout
>>> paradex = Paradex(env=Environment.TESTNET, ws_timeout=30)
>>> # With simulator-friendly injection (high-frequency, no sleeps)
>>> paradex = Paradex(env=Environment.TESTNET, auto_start_ws_reader=False,
...                   http_client=custom_client, ws_connector=custom_connector,
...                   ws_reader_sleep_on_error=0, ws_reader_sleep_on_no_connection=0)

__init__(env, l1_address=None, l1_private_key=None, l2_private_key=None, logger=None, ws_timeout=None, http_client=None, api_base_url=None, default_timeout=None, retry_strategy=None, request_hook=None, auto_start_ws_reader=True, ws_connector=None, ws_url_override=None, ws_reader_sleep_on_error=1.0, ws_reader_sleep_on_no_connection=1.0, validate_ws_messages=False, ping_interval=None, disable_reconnect=False, auto_auth=True, auth_provider=None, signer=None)

init_account(l1_address, l1_private_key=None, l2_private_key=None)

Initialize paradex account with l1 or l2 private keys. Cannot be called if account is already initialized.

Parameters:

Name Type Description Default
l1_address str

L1 address

required
l1_private_key str

L1 private key

None
l2_private_key str

L2 private key

None

L2-Only Authentication (Subkeys)

For users who only have L2 credentials (subkeys) and don't need L1 onboarding:

paradex_py.paradex_subkey.ParadexSubkey

ParadexSubkey class for L2-only authentication using subkeys.

This class extends Paradex functionality but uses SubkeyAccount for L2-only authentication without requiring L1 credentials.

Parameters:

Name Type Description Default
env Environment

Environment

required
l2_private_key str

L2 private key (required)

required
l2_address str

L2 address of the main account (required)

required
logger Logger

Logger. Defaults to None.

None
ws_timeout int

WebSocket read timeout in seconds. Defaults to None (uses default).

None

Examples:

>>> from paradex_py import ParadexSubkey
>>> from paradex_py.environment import Environment
>>> paradex = ParadexSubkey(
...     env=Environment.TESTNET,
...     l2_private_key="0x...",
...     l2_address="0x..."
... )
>>> # With custom timeout
>>> paradex = ParadexSubkey(
...     env=Environment.TESTNET,
...     l2_private_key="0x...",
...     l2_address="0x...",
...     ws_timeout=30
... )

init_account() async

Initialize account for L2-only authentication.

This method is provided for compatibility with the Paradex interface, but the account is already initialized in init for subkeys.

Usage Examples

L1 + L2 Authentication (Traditional):

from paradex_py import Paradex
from paradex_py.environment import Environment

# Requires both L1 and L2 credentials
paradex = Paradex(
    env=Environment.TESTNET,
    l1_address="0x...",
    l1_private_key="0x..."
)

L2-Only Authentication (Subkeys):

from paradex_py import ParadexSubkey
from paradex_py.environment import Environment

# Only requires L2 credentials - no L1 needed
paradex = ParadexSubkey(
    env=Environment.TESTNET,
    l2_private_key="0x...",
    l2_address="0x..."
)

# Use exactly like regular Paradex
await paradex.init_account()  # Already initialized
markets = await paradex.api_client.get_markets()

WebSocket Usage:

async def on_message(ws_channel, message):
    print(ws_channel, message)

await paradex.ws_client.connect()
await paradex.ws_client.subscribe(ParadexWebsocketChannel.MARKETS_SUMMARY, callback=on_message)

When to Use Each Approach

Use Paradex (L1 + L2) when: - You have both L1 (Ethereum) and L2 (Starknet) credentials - You have never logged in to Paradex using this account before - You need to perform on-chain operations (transfers, withdrawals)

Use ParadexSubkey (L2-only) when: - You only have L2 credentials - The account has already been onboarded (You have logged in to Paradex before) - You do not need on-chain operations (withdrawals, transfers)

Key Differences

Feature Paradex ParadexSubkey
Authentication L1 + L2 L2-only
Onboarding ✅ Supported ❌ Blocked
On-chain Operations ✅ Supported ❌ Blocked
API Access ✅ Full access ✅ Full access
WebSocket ✅ Supported ✅ Supported
Order Management ✅ Supported ✅ Supported

Full details for REST API & WebSocket JSON-RPC API can be found at the following links:

paradex_py.api.api_client.ParadexApiClient

Bases: BlockTradesMixin, HttpClient

Class to interact with Paradex REST API. Initialized along with Paradex class.

Parameters:

Name Type Description Default
env Environment

Environment

required
logger Logger

Logger. Defaults to None.

None
http_client HttpClient

Custom HTTP client for injection. Defaults to None.

None
api_base_url str

Custom base URL override. Defaults to None.

None
auto_auth bool

Whether to automatically handle onboarding/auth. Defaults to True.

True
auth_provider AuthProvider

Custom authentication provider. Defaults to None.

None
signer Signer

Custom order signer for submit/modify/batch operations. Defaults to None.

None

Examples:

>>> from paradex_py import Paradex
>>> from paradex_py.environment import Environment
>>> paradex = Paradex(env=Environment.TESTNET)

cancel_all_orders(params=None)

Cancel all open orders for specific market or for all markets. Private endpoint requires authorization.

Parameters:

Name Type Description Default
params dict | None

market: Market Name

None

cancel_order(order_id)

Cancel open order previously sent to Paradex from this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
order_id str

Order Id

required

cancel_order_by_client_id(client_id)

Cancel open order previously sent to Paradex from this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
client_id str

Order id as assigned by a trader.

required

cancel_orders_batch(order_ids=None, client_order_ids=None)

Cancel batch of orders by order IDs or client order IDs. Private endpoint requires authorization.

Parameters:

Name Type Description Default
order_ids list[str] | None

List of order IDs assigned by Paradex

None
client_order_ids list[str] | None

List of client-assigned order IDs

None

Returns:

Name Type Description
results list

List of cancellation results for each order

fetch_account_info()

Fetch profile for this account. Private endpoint requires authorization.

fetch_account_profile()

Fetch profile for this account. Private endpoint requires authorization.

fetch_account_summary()

Fetch current summary for this account. Private endpoint requires authorization.

fetch_balances()

Fetch all coin balances for this account. Private endpoint requires authorization.

Returns:

Name Type Description
results list

List of Balances

fetch_bbo(market)

Fetch best bid/offer for specific market.

Parameters:

Name Type Description Default
market str

Market Name

required

fetch_fills(params=None)

Fetch history of fills for this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
params dict | None

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

market: Market for the fills

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

None

Returns:

Name Type Description
next str

The pointer to fetch next set of records (null if there are no records left)

prev str

The pointer to fetch previous set of records (null if there are no records left)

results list

List of Fills

fetch_funding_data(params=None)

List historical funding data by market

Parameters:

Name Type Description Default
params dict | None

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

market: Market for which funding payments are queried

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

None

Returns:

Name Type Description
next str

The pointer to fetch next set of records (null if there are no records left)

prev str

The pointer to fetch previous set of records (null if there are no records left)

results list

List of Funding Payments

fetch_funding_payments(params=None)

Fetch history of funding payments for this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
params dict | None

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

market: Market for which funding payments are queried

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

None

Returns:

Name Type Description
next str

The pointer to fetch next set of records (null if there are no records left)

prev str

The pointer to fetch previous set of records (null if there are no records left)

results list

List of Funding Payments

fetch_insurance_fund()

Fetch insurance fund information

fetch_klines(symbol, resolution, start_at, end_at, price_kind=None)

Fetch OHLCV candlestick data for a symbol.

Parameters:

Name Type Description Default
symbol str

Symbol of the market pair

required
resolution str

Resolution in minutes: 1, 3, 5, 15, 30, 60

required
start_at int

Start time for klines in milliseconds

required
end_at int

End time for klines in milliseconds

required
price_kind str | None

Which price to use for the klines (optional)

None

Returns:

Type Description
dict

List of OHLCV candlestick data

fetch_liquidations(params=None)

Fetch history of liquidations for this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
params dict | None

start (int): start time in milliseconds since epoch. end (int): end time in milliseconds since epoch.

None

Returns:

Name Type Description
results list

List of Liquidations

fetch_markets(params=None)

Fetch all markets information.

Parameters:

Name Type Description Default
params dict | None

market: Market Name

None

Returns:

Name Type Description
results list

List of Markets

fetch_markets_summary(params=None)

Fetch ticker information for specific market.

Parameters:

Name Type Description Default
params dict | None

end: End Time (unix time millisecond)

market: Name of the market for which summary is requested (for all available markets use ALL)

start: Start Time (unix time millisecond)

None

Returns:

Name Type Description
results list

List of Market Summaries

fetch_order(order_id)

Fetch a state of specific order sent from this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
order_id str

order's id as assigned by Paradex.

required

fetch_order_by_client_id(client_id)

Fetch a state of specific order sent from this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
client_id str

order's client_id as assigned by a trader.

required

fetch_orderbook(market, params=None)

Fetch order-book for specific market.

Parameters:

Name Type Description Default
market str

Market Name

required
params dict | None

depth: Depth

None

fetch_orders(params=None)

Fetch open orders for the account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
params dict | None

market: Market for the order

None

Returns:

Name Type Description
results list

Orders list

fetch_orders_history(params=None)

Fetch history of orders for the account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
params dict | None

client_id: Unique ID of client generating the order

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

market: Market for the order

page_size: Limit the number of responses in the page

side: Order side

start_at: Start Time (unix time millisecond)

status: Order status

type: Order type

None

Returns:

Name Type Description
next str

The pointer to fetch next set of records (null if there are no records left)

prev str

The pointer to fetch previous set of records (null if there are no records left)

results list

List of Orders

fetch_points_data(market, program)

Fetch points program data for specific market. Private endpoint requires authorization.

Parameters:

Name Type Description Default
market str

Market Name

required
program str

Program Name - example: Maker, Fee

required

Returns:

Name Type Description
results list

List of points data

fetch_positions()

Fetch all derivatives positions for this account. Private endpoint requires authorization.

Returns:

Name Type Description
next str

The pointer to fetch next set of records (null if there are no records left)

prev str

The pointer to fetch previous set of records (null if there are no records left)

results list

List of Positions

fetch_subaccounts()

Fetch list of sub-accounts for this account. Private endpoint requires authorization.

fetch_system_config()

Fetch Paradex system config.

Examples:

>>> paradex.api_client.fetch_system_config()
>>> { ..., "paraclear_decimals": 8, ... }

fetch_system_state()

Fetch Paradex system status.

Examples:

>>> paradex.api_client.fetch_system_state()
>>> { "status": "ok" }

fetch_system_time()

Fetch Paradex system time.

Examples:

>>> paradex.api_client.fetch_system_time()
>>> { "server_time": "1710956478221" }

Returns:

Name Type Description
server_time dict

Paradex Server time

fetch_tradebusts(params=None)

Fetch history of tradebusts for this account.

Parameters:

Name Type Description Default
params dict | None

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

None

Returns:

Name Type Description
next str

The pointer to fetch next set of records (null if there are no records left)

prev str

The pointer to fetch previous set of records (null if there are no records left)

results list

List of Tradebusts

fetch_trades(params)

Fetch Paradex exchange trades for specific market.

Parameters:

Name Type Description Default
params dict

market: Market Name

required

Returns:

Name Type Description
next str

The pointer to fetch next set of records (null if there are no records left)

prev str

The pointer to fetch previous set of records (null if there are no records left)

results list

List of Trades

fetch_transactions(params=None)

Fetch history of transactions initiated by this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
params dict | None

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

None

Returns:

Name Type Description
next str

The pointer to fetch next set of records (null if there are no records left)

prev str

The pointer to fetch previous set of records (null if there are no records left)

results list

List of Transactions

fetch_transfers(params=None)

Fetch history of transfers initiated by this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
params dict | None

cursor: Returns the next paginated page

end_at: End Time (unix time millisecond)

page_size: Limit the number of responses in the page

start_at: Start Time (unix time millisecond)

status: none

None

Returns:

Name Type Description
next str

The pointer to fetch next set of records (null if there are no records left)

prev str

The pointer to fetch previous set of records (null if there are no records left)

results list

List of Transfers

modify_order(order_id, order, signer=None)

Modify an open order previously sent to Paradex from this account. Private endpoint requires authorization.

Parameters:

Name Type Description Default
order_id str

Order Id

required
order Order

Order update

required
signer Signer | None

Optional custom signer. Uses instance signer or account signer if None.

None

set_token(jwt)

Inject a JWT token without HTTP calls.

Useful for simulation and testing scenarios where you want to bypass the normal authentication flow.

Parameters:

Name Type Description Default
jwt str

JWT token string

required

submit_order(order, signer=None)

Send order to Paradex. Private endpoint requires authorization.

Parameters:

Name Type Description Default
order Order

Order containing all required fields.

required
signer Signer | None

Optional custom signer. Uses instance signer or account signer if None.

None

submit_orders_batch(orders, signer=None)

Send batch of orders to Paradex. Private endpoint requires authorization.

Parameters:

Name Type Description Default
orders list[Order]

List of orders containing all required fields.

required
signer Signer | None

Optional custom signer. Uses instance signer or account signer if None.

None

Returns:

Name Type Description
orders list

List of Orders

errors list

List of Errors

paradex_py.api.ws_client.ParadexWebsocketChannel

Bases: Enum

Enum class to define the channels for Paradex Websocket API.

Attributes:

Name Type Description
ACCOUNT str

Private websocket channel for receiving updates of account status

BALANCE_EVENTS str

Private websocket channel to receive PnL calculation data

BBO str

Public websocket channel for tick updates of orderbook best bid/ask prices and amounts

FILLS str

Private websocket channel to receive details of fills for specific account

FUNDING_DATA str

Public websocket channel to receive funding data updates

FUNDING_PAYMENTS str

Private websocket channel to receive funding payments of an account

FUNDING_RATE_COMPARISON str

Public websocket channel for funding rate comparisons across exchanges

MARKETS_SUMMARY str

Public websocket channel for updates of available markets

ORDERS str

Private websocket channel to receive order updates

ORDER_BOOK str

Public websocket channel for orderbook snapshot updates of depth 15 at most every 50ms or 100ms, optionally grouped by price tick

POSITIONS str

Private websocket channel to receive updates when position is changed

TRADES str

Public websocket channel to receive updates on trades in particular market

TRADEBUSTS str

Private websocket channel to receive fills that are busted by a blockchain

TRANSACTIONS str

Private websocket channel for receiving transaction details of fills

TRANSFERS str

Websocket channel for receiving transfer updates

paradex_py.api.ws_client.ParadexWebsocketClient

Class to interact with Paradex WebSocket JSON-RPC API. Initialized along with Paradex class.

Parameters:

Name Type Description Default
env Environment

Environment

required
logger Optional[Logger]

Logger. Defaults to None.

None
ws_timeout Optional[int]

WebSocket read timeout in seconds. Defaults to 20s.

None
auto_start_reader bool

Whether to automatically start the message reader. Defaults to True.

True
connector Optional[WebSocketConnector]

Custom WebSocket connector for injection. Defaults to None.

None
ws_url_override Optional[str]

Custom WebSocket URL override. Defaults to None.

None
reader_sleep_on_error float

Sleep duration after connection errors. Set to 0 for no sleep. Defaults to 1.0.

1.0
reader_sleep_on_no_connection float

Sleep duration when no connection. Set to 0 for no sleep. Defaults to 1.0.

1.0
validate_messages bool

Enable pydantic message validation. Requires pydantic. Defaults to False.

False
ping_interval float

WebSocket ping interval in seconds. None uses websockets default. Defaults to None.

None
disable_reconnect bool

Disable automatic reconnection for tight simulation control. Defaults to False.

False

Examples:

>>> from paradex_py import Paradex
>>> from paradex_py.environment import Environment
>>> paradex = Paradex(env=Environment.TESTNET)
>>> paradex.ws_client.connect()
>>> # With custom timeout
>>> from paradex_py.api.ws_client import ParadexWebsocketClient
>>> ws_client = ParadexWebsocketClient(env=Environment.TESTNET, ws_timeout=30)
>>> # With manual pumping disabled
>>> ws_client = ParadexWebsocketClient(env=Environment.TESTNET, auto_start_reader=False)
>>> # High-frequency simulator mode (no sleeps)
>>> ws_client = ParadexWebsocketClient(env=Environment.TESTNET,
...                                   reader_sleep_on_error=0, reader_sleep_on_no_connection=0)
>>> # With typed message validation
>>> ws_client = ParadexWebsocketClient(env=Environment.TESTNET, validate_messages=True)

connect() async

Connect to Paradex WebSocket API.

Returns:

Name Type Description
bool bool

True if connection is successful.

Examples:

>>> from paradex_py import Paradex
>>> from paradex_py.environment import TESTNET
>>> async def main():
...     paradex = Paradex(env=TESTNET)
...     await paradex.ws_client.connect()
>>> import asyncio
>>> asyncio.run(main())

get_subscriptions()

Get current subscription map.

Returns:

Type Description
dict[str, bool]

Dictionary mapping channel names to subscription status

inject(message) async

Inject a raw message string into the message processing pipeline.

Parameters:

Name Type Description Default
message str

Raw JSON string to process as if received from WebSocket.

required

pump_once() async

Manually pump one message from the WebSocket connection.

Returns:

Name Type Description
bool bool

True if a message was processed, False if no message available or connection closed.

pump_until(predicate, timeout_s=10.0) async

Deterministic consumption helper for simulators.

Pumps messages until predicate returns True or timeout is reached. Useful for waiting for specific message conditions in tests.

Parameters:

Name Type Description Default
predicate Callable[[dict], bool]

Function that takes a message dict and returns True to stop

required
timeout_s float

Maximum time to wait in seconds

10.0

Returns:

Type Description
int

Number of messages processed before predicate was satisfied or timeout

Examples:

Wait for BBO message with specific price

count = await ws_client.pump_until( lambda msg: msg.get('params', {}).get('channel', '').startswith('bbo') and float(msg.get('data', {}).get('bid', 0)) > 50000, timeout_s=5.0 )

subscribe(channel, callback, params=None) async

Subscribe to a websocket channel with optional parameters. Callback function is invoked when a message is received.

Parameters:

Name Type Description Default
channel ParadexWebsocketChannel

Channel to subscribe

required
callback Callable

Callback function

required
params Optional[dict]

Parameters for the channel. Defaults to None.

None

Examples:

from paradex_py import Paradex from paradex_py.environment import TESTNET from paradex_py.api.ws_client import ParadexWebsocketChannel, ParadexWebsocketClient async def main(): ... async def on_message(ws_channel, message): ... print(ws_channel, message) ... paradex = Paradex(env=TESTNET) ... await paradex.ws_client.connect() ... await paradex.ws_client.subscribe(ParadexWebsocketChannel.MARKETS_SUMMARY, callback=on_message) import asyncio asyncio.run(main())

subscribe_by_name(channel_name, callback=None) async

Subscribe to a channel by exact name string.

This is useful for simulation tooling where you want to subscribe to channels with exact names without using the enum formatting.

Parameters:

Name Type Description Default
channel_name str

Exact channel name (e.g., "bbo.BTC-USD-PERP")

required
callback Callable | None

Optional callback function. If provided, registers the callback.

None

unsubscribe_by_name(channel_name) async

Unsubscribe from a channel by exact name string.

Symmetric with subscribe_by_name for complete channel lifecycle control.

Parameters:

Name Type Description Default
channel_name str

Exact channel name (e.g., "bbo.BTC-USD-PERP")

required

paradex_py.account.account.ParadexAccount

Class to generate and manage Paradex account. Initialized along with Paradex class.

Parameters:

Name Type Description Default
config SystemConfig

SystemConfig

required
l1_address str

Ethereum address

required
l1_private_key Optional[str]

Ethereum private key. Defaults to None.

None
l2_private_key Optional[str]

Paradex private key. Defaults to None.

None

Examples:

>>> from paradex_py import Paradex
>>> from paradex_py.environment import Environment
>>> paradex = Paradex(env=Environment.TESTNET, l1_address="0x...", l1_private_key="0x...")
>>> paradex.account.l2_address
>>> paradex.account.l2_public_key
>>> paradex.account.l2_private_key

sign_block_offer(offer_data)

Sign block offer data using Starknet account. Args: offer_data (dict): Block offer data containing offer details Returns: dict: Signed block offer data

sign_block_trade(block_trade_data)

Sign block trade data using Starknet account. Args: block_trade_data (dict): Block trade data containing trade details Returns: dict: Signed block trade data

paradex_py.account.subkey_account.SubkeyAccount

Bases: ParadexAccount

Subkey account for L2-only API authentication (no on-chain operations).

This account type is designed for subkey usage where only L2 credentials are available and no L1 onboarding is required.

Parameters:

Name Type Description Default
config SystemConfig

SystemConfig

required
l2_private_key str

L2 private key (required)

required
l2_address str

L2 address of the main account (required)

required

Examples:

>>> from paradex_py.account.subkey_account import SubkeyAccount
>>> from paradex_py.environment import Environment
>>> account = SubkeyAccount(
...     config=config,
...     l2_private_key="0x...",
...     l2_address="0x..."
... )

onboarding_headers()

Override to prevent onboarding for subkeys.

transfer_on_l2(target_l2_address, amount_decimal)

Override to prevent on-chain operations for subkeys.