A simple Python API wrapper for DEXTools. Supports Dextools API v1 and Dextools API v2
pip install dextools-python
To obtain an API key, head to the Developer Portal and choose your plan.
There are 2 versions of the Dextools API. Dextools API v1 and Dextools API v2
To get started, import the package, and initiate a DextoolsAPI
instance object by passing your API key:
from dextools_python import DextoolsAPI
dextools = DextoolsAPI(api_key)
You can also pass an optional user agent:
dextools = DextoolsAPI(api_key, useragent="User-Agent")
To get started, import the package, and initiate a DextoolsAPIV2
instance object by passing your API key and your plan:
from dextools_python import DextoolsAPIV2
dextools = DextoolsAPIV2(api_key, plan="free")
You can also pass an optional user agent:
dextools = DextoolsAPIV2(api_key, useragent="User-Agent", plan="free")
If you don't specify any plan when instantiating the object, it will default to "partner" plan
You can setup your plan when setting the object instance by providing the plan
argument in the constructor. If no plan
is specified, it will default to "partner" plan
To set your plan after the object is created, you can use the set_plan("your_plan")
method
dextools.set_plan("standard")
Available values: "free"
, "standard"
, "advanced"
, "pro"
, and "partner"
Below are a set of queries supported by the Dextools API v1. All data is returned as a Python dictionary for easy data handling.
To get the pairs of a token, pass a chain id
and a pair address
:
pair = dextools.get_pair("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
print(pair)
To get token details, pass a chain id
, and a token address
:
token = dextools.get_token("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
print(token)
You can also pass the page
and pageSize
parameters:
token = dextools.get_token("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a", 1, 50)
print(token)
To get the chain list:
chain_list = dextools.get_chain_list()
print(chain_list)
You can also pass the page
and pageSize
parameters:
chain_list = dextools.get_chain_list(1, 50)
print(chain_list)
To get the exchange list, pass a chain id
:
exchange_list = dextools.get_exchange_list("ether")
print(exchange_list)
You can also pass the page
and pageSize
parameters:
exchange_list = dextools.get_exchange_list("ether", 1, 50)
print(exchange_list)
Below are a set of queries supported by the Dextools API v2. All data is returned as a Python dictionary for easy data handling.
blockchain = dextools.get_blockchain("ether")
print(blockchain)
blockchains = dextools.get_blockchains()
print(blockchains)
blockchains = dextools.get_blockchains(sort="name", order="desc")
print(blockchains)
factory = dextools.get_dex_factory_info("ether", "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f")
print(factory)
dexes = dextools.get_dexes("ether")
print(dexes)
dexes = dextools.get_dexes("ether", sort="creationBlock", order="desc")
print(dexes)
pool = dextools.get_pool("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
print(pool)
pool_liquidity = dextools.get_pool_liquidity("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
print(pool_liquidity)
pool_score = dextools.get_pool_score("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
print(pool_score)
pool_price = dextools.get_pool_price("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
print(pool_price)
pools = dextools.get_pools("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
print(pools)
pools = dextools.get_pools("ether", from_="12755070", to="12755071", sort="creationBlock", order="desc")
print(pools)
token = dextools.get_token("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
print(token)
token_locks = dextools.get_token_locks("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
print(token_locks)
token_score = dextools.get_token_score("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
print(token_score)
token_info = dextools.get_token_info("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
print(token_info)
token_price = dextools.get_token_price("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
print(token_price)
tokens = dextools.get_tokens("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
print(tokens)
Get tokens sorted by creationBlock
and descending order and providing block numbers instead in descending order
tokens = dextools.get_tokens("ether", from_="18570000", to="18570500", sort="creationBlock", order="desc")
print(tokens)
tokens = dextools.get_tokens("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00", sort="socialsInfoUpdated", order="desc")
print(tokens)
token_pools = dextools.get_token_pools("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
print(token_pools)
Get token pools sorted by creationBlock
and descending order and providing block numbers instead in descending order
token_pools = dextools.get_token_pools("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a", from_="18570000", to="18570500", sort="creationBlock", order="desc")
print(token_pools)
hot_pools = dextools.get_ranking_hotpools("ether")
print(hot_pools)
gainers = dextools.get_ranking_gainers("ether")
print(gainers)
losers = dextools.get_ranking_losers("ether")
print(losers)
Some methods support the page
and pageSize
arguments. Check out the Dextools API v2 documentation for more information.
Check out the examples
folder for some example scripts.
A set of tests have been included inside tests
folder. You will need to set an environment variable as DextoolsAPIKey
using your API key.
Dextools adds support for new blockchains from time to time. dextools.get_blockchains()
to get a list of supported blockchains and their IDs