Registry / http-networking / ccxt
library4.5.76pypypi✓ verified 28d ago

CCXT (Cryptocurrency eXchange Trading Library) is a JavaScript / TypeScript / Python / C# / PHP / Go library providing a unified API for connecting to and trading with over 100 cryptocurrency exchanges worldwide. It offers quick access to market data (tickers, order books, OHLCV, trade history) and enables algorithmic trading functionalities like placing market/limit orders, managing balances, and handling deposits/withdrawals. The library is actively maintained with frequent updates and new exchange integrations.

pip install ccxt
INSTALL
IMPORT
SIG · CCXT
C
ccxt
http-networkingpythonv4.5.76
Install
9.7s avg
Import
2435ms
Disk
125MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v4.5.76 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 2.586s · 117.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 9.7s · import 2.284s · 123MB
125MB installed
● package 125MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ccxt
✓ import ccxt
Standard synchronous import.
ccxt.async_support
✓ import ccxt.async_support as ccxt
Import for asynchronous operations (requires Python 3.7+ and `asyncio`).

This quickstart demonstrates how to instantiate an exchange client and fetch public market data (a ticker) for a specified symbol. It includes basic error handling and illustrates how to configure rate limiting. For private API access (e.g., fetching balance, placing orders), API keys are required and should be loaded securely, ideally from environment variables.

import ccxt import os exchange_id = 'binance' exchange_class = getattr(ccxt, exchange_id) # Public API access (no API keys needed for public data) exchange = exchange_class({ 'rateLimit': 1200, 'enableRateLimit': True, # Important for respecting exchange limits }) try: # Fetch ticker for a symbol symbol = 'BTC/USDT' ticker = exchange.fetch_ticker(symbol) print(f"Fetched ticker for {symbol} on {exchange_id}: {ticker['last']} (last price)") # For private API, uncomment and replace with actual keys (use environment variables in production) # exchange_private = exchange_class({ # 'apiKey': os.environ.get('CCXT_BINANCE_API_KEY', ''), # 'secret': os.environ.get('CCXT_BINANCE_SECRET', ''), # 'rateLimit': 1200, # 'enableRateLimit': True, # }) # if exchange_private.apiKey and exchange_private.secret: # balance = exchange_private.fetch_balance() # print(f"Fetched balance for {exchange_id}: {balance['total']}") except ccxt.NetworkError as e: print(f"Network error: {type(e).__name__} {str(e)}") except ccxt.ExchangeError as e: print(f"Exchange error: {type(e).__name__} {str(e)}") except Exception as e: print(f"An unexpected error occurred: {type(e).__name__} {str(e)}")
Debug
Known issues
gotchaAlways enable and configure rate limiting to avoid being banned by exchanges. Set `enableRateLimit: True` and adjust `rateLimit` (in milliseconds) as needed, especially for high-frequency operations. Default `rateLimit` values may not always prevent issues with aggressive API usage.
fix
Initialize exchange with `{'rateLimit': <milliseconds>, 'enableRateLimit': True}`. Increase `rateLimit` if encountering `DDoSProtection` or `RateLimitExceeded` errors.
affects: All
gotchaHandle API keys and secrets securely. Never hardcode them directly in your script, especially when using private API methods. Use environment variables or a secure configuration management system.
fix
Load API keys and secrets from environment variables (e.g., `os.environ.get('API_KEY')`) or a separate, untracked configuration file.
affects: All
gotchaDifferentiate between synchronous (`import ccxt`) and asynchronous (`import ccxt.async_support as ccxt`) imports. Using asynchronous methods (e.g., `await exchange.fetch_ticker`) requires the `async_support` module and an `asyncio` event loop. Mixing them without proper handling will lead to runtime errors.
fix
For async operations, use `import ccxt.async_support as ccxt` and ensure all API calls are `await`-ed within an `async` function. For sync, use `import ccxt` and regular blocking calls.
affects: Python 3.5.3+
gotchaImplement robust error handling for network and exchange-specific issues. API calls can fail due to network problems, exchange-specific errors (e.g., invalid symbol, insufficient funds), or rate limits.
fix
Wrap API calls in `try...except` blocks, specifically catching `ccxt.NetworkError`, `ccxt.ExchangeError`, and a general `Exception` for unexpected issues.
affects: All
breakingWhile CCXT aims for a unified interface, underlying exchange APIs frequently change. These changes, though often abstracted, can sometimes lead to unexpected behavior or require minor adjustments to your code (e.g., changes in error messages, supported parameters, or data formats for specific exchanges).
fix
Regularly update the library and review the CCXT GitHub releases and changelogs. Test your application thoroughly after updating. Check `exchange.has` properties for exchange-specific capabilities.
affects: Across major CCXT updates (e.g., v3 to v4) and frequent minor updates.
gotchaCCXT.Pro, a distinct (though integrated) part of the library, provides WebSocket APIs for real-time, high-frequency trading. It has different `watch*` methods and incremental data structures. The standard CCXT library primarily uses REST APIs.
fix
Understand whether you need REST (standard CCXT) or WebSocket (CCXT.Pro) functionality. Use `ccxt.pro` for real-time streams and be aware of its specific `watch*` methods and caching mechanisms. The examples folder in the CCXT GitHub repository provides separate examples for `ccxt.pro`.
affects: All
Errors
Common errors & fixes
ccxt.base.errors.AuthenticationError
This error occurs when the provided API key, secret, or passphrase is incorrect, expired, or lacks the necessary permissions on the cryptocurrency exchange.
fix
Double-check your API credentials (key, secret, passphrase) for typos. Ensure the API key has the correct permissions enabled on the exchange (e.g., 'Spot Trading', 'Read Data', 'Withdrawals' if applicable) and is not restricted by IP address if you are running from a different location. Regenerate the API key/secret on the exchange if necessary.
ModuleNotFoundError: No module named 'ccxt'
The `ccxt` library is not installed in the Python environment currently being used, or there is an issue with the Python interpreter's path.
fix
Install the library using pip: `pip install ccxt`. If you are using multiple Python versions or virtual environments, ensure you are installing it into and running your script from the correct environment (e.g., `pip3 install ccxt` or activate your virtual environment before installing).
ccxt.base.errors.ExchangeNotAvailable
This error indicates that the exchange's API is currently unavailable, experiencing server issues, undergoing maintenance, or your access is blocked due to network problems or geographical restrictions.
fix
Check the exchange's official status page or social media for announcements about downtime or maintenance. Ensure your internet connection is stable. If running from a cloud server, verify that your server's IP address is not blocked by the exchange due to geographic restrictions or policy violations. Implement retry logic with exponential backoff for transient network issues.
ccxt.base.errors.RateLimitExceeded
Your script is making API requests to the exchange too frequently, exceeding the exchange's imposed rate limits.
fix
Enable CCXT's built-in rate limiting feature by setting `exchange.enableRateLimit = True` after initializing the exchange object. If the issue persists, introduce manual delays between API calls using `time.sleep()` or restructure your code to fetch data less often or in larger batches.
Upgrade
Version history
4.5.76latest on PyPI · released Aug 26, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
46 hits · last 30 days
node
42
OpenAI (training)
1
Resources