Package: idex-sdk
Python SDKThe official library forIDEX v3'sREST and WebSocket APIs, featuring a real time order book implementation with support forhybrid liquidity.Complete documentation for the IDEX v3 API is available athttps://api-docs-v3.idex.io.The IDEX Python SDK is currently in beta.Installationpipinstallidex-sdkGetting StartedSign up forAPI keys. Market data endpoints do not require an account.A fully-functionaltestnet sandboxis available for development.In-depth usage documentation by endpoint isavailable here.Usage ExamplesPublic REST API Clientfromidex_sdk.client.rest.publicimportRestPublicClientc=RestPublicClient()exchange_info=c.get_exchange_info()assets=c.get_assets()markets=c.get_markets()candles=c.get_candles({"market":"ETH-USDC","interval":"1h"})order_book_l2=c.get_order_book_level2("ETH-USDC")Authenticated REST API Clientfromuuidimportuuid1fromidex_sdk.client.rest.authenticatedimportRestAuthenticatedClientdefuuid()->str:returnstr(uuid1())c=RestAuthenticatedClient(api_key="<API key>",api_secret="<API secret>",wallet_private_key="<wallet private key>",)wallet_address="<wallet address>"get_balances=c.get_balances({"nonce":uuid(),"wallet":wallet_address,})new_order=c.create_order({"nonce":uuid(),"wallet":wallet_address,"market":"ETH-USDC","type":"limit","side":"buy","quantity":"1.00000000","price":"1000.00000000",})Real Time Order Book Clientimportasynciofromidex_sdk.client.order_book.real_timeimportOrderBookRealTimeClientdefupdate_l2_order_book(market:str)->None:real_time_order_book=client.get_order_book_l2(market,10)print(real_time_order_book)defmake_client()->OrderBookRealTimeClient:client=OrderBookRealTimeClient()client.on("l2",update_l2_order_book)client.on("ready",update_l2_order_book)client.on("error",lambdaerror:print(f"error{error}"))returnclientclient=make_client()asyncdeftest()->None:task=asyncio.create_task(client.start(["IDEX-USDC"]))awaittaskif__name__=="__main__":asyncio.run(test())About the Python SDKThis is a python conversion of theIDEX Typescript SDK. There is a conversion of all functionality, including typing withmypy. There are some small differences in how theOrderBookRealTimeClientis run by external code due to differences in how Python'sasynciolibrary handles asynchronous code compares to Javascript. See the example code below for more information.Setup RepositoryEnsure python3 andpoetryare installed.Clone repoCd into repo directoryRunpoetry installThe project is now installed to a virtual environment at./.venv. Use this environment in the terminal by runningpoetry shell, or by pointing your IDE to it. For example, loading the project directory in VSCode with the Python extension installed should automatically prompt to select the virtual environment.The project includes configuration (inpyproject.toml) for type-checking wihmypy, debugging withdebugpy(for IDEs like neovim), linting withflake8, auto-formatting withblack, and sorting imports withisort. If you configure your IDE appropriately, all of this will be automatic. An example VSCode configuration is included.TestingUnit tests are available (usingpython unittest) for logic-heavy functionality. To run them, runmake test.Generating docspydoc-markdown -I idex_sdk --render-toc > docs.mdContract ABIsIncluded in thecontracts/directory contains the ABIs necessary for interacting with IDEX v3's smart contracts.TheExchange ABIcan be used to query contract state,deposit funds,add liquidity,remove liquidityorexit wallets.TheFaucetToken ABIis implemented by theAPI sandboxtestnet tokens and features afaucetfunction for dispensing tokens.Getting HelpPlease reach out in the#developers Discordfor help, oropen an issueto report bugs.LicenseThe IDEX Python SDK is released under theMIT License.