{"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":"python","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,"search_vec":"'100':27 'access':34 'activ':61 'algo':75 'algo-trad':74 'algorithm':46 'api':19,73 'balanc':54 'book':40 'c':12 'ccxt':1,2 'connect':21 'cryptocurr':3,28,70 'data':37 'deposits/withdrawals':57 'enabl':45 'exchang':4,29,68,72 'financi':77 'frequent':64 'function':48 'go':14 'handl':56 'histori':43 'integr':69 'javascript':9 'librari':6,15,59 'like':49 'maintain':62 'manag':53 'market':36 'market/limit':51 'new':67 'offer':32 'ohlcv':41 'order':39,52 'php':13 'place':50 'provid':16 'python':11 'quick':33 'ticker':38 'trade':5,24,42,47,71,76 'typescript':10 'unifi':18 'updat':65 'worldwid':30","created_at":"2026-04-11T01:27:36.450788+00:00","updated_at":"2026-04-16T01:35:51.164921+00:00","problems":[{"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.","cause":"This error occurs when the provided API key, secret, or passphrase is incorrect, expired, or lacks the necessary permissions on the cryptocurrency exchange.","error":"ccxt.base.errors.AuthenticationError"},{"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).","cause":"The `ccxt` library is not installed in the Python environment currently being used, or there is an issue with the Python interpreter's path.","error":"ModuleNotFoundError: No module named 'ccxt'"},{"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.","cause":"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.","error":"ccxt.base.errors.ExchangeNotAvailable"},{"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.","cause":"Your script is making API requests to the exchange too frequently, exceeding the exchange's imposed rate limits.","error":"ccxt.base.errors.RateLimitExceeded"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.5.76","cli_name":"","cli_version":null,"type":"library","homepage":"https://ccxt.com","github":"https://github.com/ccxt/ccxt","docs":"https://github.com/ccxt/ccxt/wiki","changelog":null,"pypi":"https://pypi.org/project/ccxt/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}