{"id":2425,"library":"ccxt","title":"CCXT","description":"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.","status":"active","version":"4.5.48","language":"en","source_language":"en","source_url":"https://github.com/ccxt/ccxt","tags":["cryptocurrency","trading","exchange","api","algo-trading","financial"],"install":[{"cmd":"pip install ccxt","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"Standard synchronous import.","symbol":"ccxt","correct":"import ccxt"},{"note":"Import for asynchronous operations (requires Python 3.7+ and `asyncio`).","symbol":"ccxt.async_support","correct":"import ccxt.async_support as ccxt"}],"quickstart":{"code":"import ccxt\nimport os\n\nexchange_id = 'binance'\nexchange_class = getattr(ccxt, exchange_id)\n\n# Public API access (no API keys needed for public data)\nexchange = exchange_class({\n    'rateLimit': 1200,\n    'enableRateLimit': True, # Important for respecting exchange limits\n})\n\ntry:\n    # Fetch ticker for a symbol\n    symbol = 'BTC/USDT'\n    ticker = exchange.fetch_ticker(symbol)\n    print(f\"Fetched ticker for {symbol} on {exchange_id}: {ticker['last']} (last price)\")\n\n    # For private API, uncomment and replace with actual keys (use environment variables in production)\n    # exchange_private = exchange_class({\n    #     'apiKey': os.environ.get('CCXT_BINANCE_API_KEY', ''),\n    #     'secret': os.environ.get('CCXT_BINANCE_SECRET', ''),\n    #     'rateLimit': 1200,\n    #     'enableRateLimit': True,\n    # })\n    # if exchange_private.apiKey and exchange_private.secret:\n    #     balance = exchange_private.fetch_balance()\n    #     print(f\"Fetched balance for {exchange_id}: {balance['total']}\")\n\nexcept ccxt.NetworkError as e:\n    print(f\"Network error: {type(e).__name__} {str(e)}\")\nexcept ccxt.ExchangeError as e:\n    print(f\"Exchange error: {type(e).__name__} {str(e)}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {type(e).__name__} {str(e)}\")","lang":"python","description":"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."},"warnings":[{"fix":"Initialize exchange with `{'rateLimit': <milliseconds>, 'enableRateLimit': True}`. Increase `rateLimit` if encountering `DDoSProtection` or `RateLimitExceeded` errors.","message":"Always 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.","severity":"gotcha","affected_versions":"All"},{"fix":"Load API keys and secrets from environment variables (e.g., `os.environ.get('API_KEY')`) or a separate, untracked configuration file.","message":"Handle 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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"Differentiate 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.","severity":"gotcha","affected_versions":"Python 3.5.3+"},{"fix":"Wrap API calls in `try...except` blocks, specifically catching `ccxt.NetworkError`, `ccxt.ExchangeError`, and a general `Exception` for unexpected issues.","message":"Implement 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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"While 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).","severity":"breaking","affected_versions":"Across major CCXT updates (e.g., v3 to v4) and frequent minor updates."},{"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`.","message":"CCXT.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.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}