IDEX v3 SDK for Python
Project description
Python SDK
The official library for IDEX v3's REST and WebSocket APIs, featuring a real time order book implementation with support for hybrid liquidity.
Complete documentation for the IDEX v3 API is available at https://api-docs-v3.idex.io.
The IDEX Python SDK is currently in beta.
Installation
pip install idex-sdk
Getting Started
- Sign up for API keys. Market data endpoints do not require an account.
- A fully-functional testnet sandbox is available for development.
- In-depth usage documentation by endpoint is available here.
Usage Examples
Public REST API Client
from idex_sdk.client.rest.public import RestPublicClient
c = 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 Client
from uuid import uuid1
from idex_sdk.client.rest.authenticated import RestAuthenticatedClient
def uuid() -> str:
return str(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 Client
import asyncio
from idex_sdk.client.order_book.real_time import OrderBookRealTimeClient
def update_l2_order_book(market: str) -> None:
real_time_order_book = client.get_order_book_l2(market, 10)
print(real_time_order_book)
def make_client() -> OrderBookRealTimeClient:
client = OrderBookRealTimeClient()
client.on("l2", update_l2_order_book)
client.on("ready", update_l2_order_book)
client.on("error", lambda error: print(f"error {error}"))
return client
client = make_client()
async def test() -> None:
task = asyncio.create_task(client.start(["IDEX-USDC"]))
await task
if __name__ == "__main__":
asyncio.run(test())
About the Python SDK
This is a python conversion of the IDEX Typescript SDK. There is a conversion of all functionality, including typing with mypy
. There are some small differences in how the OrderBookRealTimeClient
is run by external code due to differences in how Python's asyncio
library handles asynchronous code compares to Javascript. See the example code below for more information.
Setup Repository
- Ensure python3 and poetry are installed.
- Clone repo
- Cd into repo directory
- Run
poetry install
The project is now installed to a virtual environment at ./.venv
. Use this environment in the terminal by running poetry 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 (in pyproject.toml
) for type-checking wih mypy
, debugging with debugpy
(for IDEs like neovim), linting with flake8
, auto-formatting with black
, and sorting imports with isort
. If you configure your IDE appropriately, all of this will be automatic. An example VSCode configuration is included.
Testing
Unit tests are available (using python unittest) for logic-heavy functionality. To run them, run make test
.
Generating docs
pydoc-markdown -I idex_sdk --render-toc > docs.md
Contract ABIs
Included in the contracts/
directory contains the ABIs necessary for interacting with IDEX v3's smart contracts.
- The Exchange ABI can be used to query contract state, deposit funds, add liquidity, remove liquidity or exit wallets.
- The FaucetToken ABI is implemented by the API sandbox testnet tokens and features a faucet function for dispensing tokens.
Getting Help
Please reach out in the #developers Discord for help, or open an issue to report bugs.
License
The IDEX Python SDK is released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file idex-sdk-1.0.0b2.tar.gz
.
File metadata
- Download URL: idex-sdk-1.0.0b2.tar.gz
- Upload date:
- Size: 42.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.10.6 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d285446778200aab317221b776b4691d3c22d36e5a75871ed394f16c42728a6c |
|
MD5 | dd48aaa8c910db87cf8286e282493422 |
|
BLAKE2b-256 | be2f3a4371f716cef4633b0048c9830c2727a8d2389e8a7e83498e70a45ef288 |
File details
Details for the file idex_sdk-1.0.0b2-py3-none-any.whl
.
File metadata
- Download URL: idex_sdk-1.0.0b2-py3-none-any.whl
- Upload date:
- Size: 49.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.10.6 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 846f029c98f72bf151bcef3f05df8553c61e4e4f07942091e62dc9fcd2916629 |
|
MD5 | 4d6ef46f927b4a8946bc571ba23fb66e |
|
BLAKE2b-256 | 4cef25f369f5ddb01a463e34c1ae89370515bf040775cec4bf2d45e2da5d1621 |