Skip to content

Commit

Permalink
Added new endpoints: get pool locks and get token audit
Browse files Browse the repository at this point in the history
  • Loading branch information
alb2001 committed Nov 22, 2024
1 parent b15183a commit 6587478
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 0.3.2
+ Added Get pool locks
+ Added Get token audit
+ Updated doc with new methods
+ Updated demo examples

# Version 0.3.1
+ Separated modules
+ Added logger
Expand Down
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ Supports [Dextools API v1](https://api.dextools.io/docs) and [Dextools API v2](h
2. [Get pool liquidity](#get-pool-liquidity)
3. [Get pool score](#get-pool-score)
4. [Get pool price](#get-pool-price)
5. [Get pools](#get-pools)
6. [Get pools sorted by `creationBlock` and descending order and providing block numbers instead](#get-pools-sorted-by-creationblock-and-descending-order-and-providing-block-numbers-instead)
5. [Get pool locks](#get-pool-locks)
6. [Get pools](#get-pools)
7. [Get pools sorted by `creationBlock` and descending order and providing block numbers instead](#get-pools-sorted-by-creationblock-and-descending-order-and-providing-block-numbers-instead)
4. [Token](#token)
1. [Get token](#get-token)
2. [Get token locks](#get-token-locks)
3. [Get token score](#get-token-score)
4. [Get token info](#get-token-info)
5. [Get token price](#get-token-price)
6. [Get tokens](#get-tokens)
7. [Get tokens sorted by `creationBlock` and descending order and providing block numbers instead in descending order](#get-tokens-sorted-by-creationblock-and-descending-order-and-providing-block-numbers-instead-in-descending-order)
6. [Get token price](#get-token-audit)
7. [Get tokens](#get-tokens)
8. [Get tokens sorted by `creationBlock` and descending order and providing block numbers instead in descending order](#get-tokens-sorted-by-creationblock-and-descending-order-and-providing-block-numbers-instead-in-descending-order)
8. [Get tokens sorted by `socialsInfoUpdated` and descending order and datetimes in descending order](#get-tokens-sorted-by-socialsinfoupdated-and-descending-order-and-datetimes-in-descending-order)
9. [Get token pools](#get-token-pools)
10. [Get token pools sorted by `creationBlock` and descending order and providing block numbers instead in descending order](#get-token-pools-sorted-by-creationblock-and-descending-order-and-providing-block-numbers-instead-in-descending-order)
Expand Down Expand Up @@ -225,6 +227,12 @@ pool_price = dextools.get_pool_price("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1
print(pool_price)
```

#### Get pool locks
```
pool_locks = dextools.get_pool_locks("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
print(pool_locks)
```

#### Get pools
```
pools = dextools.get_pools("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
Expand Down Expand Up @@ -268,6 +276,12 @@ token_price = dextools.get_token_price("ether", "0xfb7b4564402e5500db5bb6d63ae67
print(token_price)
```

#### Get token audit
```
token_audit = dextools.get_token_audit("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
print(token_audit)
```

#### Get tokens
```
tokens = dextools.get_tokens("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
Expand Down
14 changes: 14 additions & 0 deletions dextools_python/async_dextools_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ async def get_pool_price(self, chain, address):
async with self._session.get(f"{self.url}{endpoint}{chain}/{address}/price", headers=self._headers) as response:
logger.debug(response.url)
return await response.json()

async def get_pool_locks(self, chain, address):
endpoint = "/pool/"

async with self._session.get(f"{self.url}{endpoint}{chain}/{address}/locks", headers=self._headers) as response:
logger.debug(response.url)
return await response.json()

async def get_pools(self, chain, from_, to, order="asc", sort="creationTime", page=None, pageSize=None):
endpoint = "/pool/"
Expand Down Expand Up @@ -135,6 +142,13 @@ async def get_token_price(self, chain, address):
async with self._session.get(f"{self.url}{endpoint}{chain}/{address}/price", headers=self._headers) as response:
logger.debug(response.url)
return await response.json()

async def get_token_audit(self, chain, address):
endpoint = "/token/"

async with self._session.get(f"{self.url}{endpoint}{chain}/{address}/audit", headers=self._headers) as response:
logger.debug(response.url)
return await response.json()

async def get_tokens(self, chain, from_, to, order="asc", sort="socialsInfoUpdated", page=None, pageSize=None):
endpoint = "/token/"
Expand Down
12 changes: 12 additions & 0 deletions dextools_python/dextools_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ def get_pool_price(self, chain, address):
response = requests.get(f"{self.url}{endpoint}{chain}/{address}/price", headers=self._headers)
logger.debug(response.url)
return response.json()

def get_pool_locks(self, chain, address):
endpoint = "/pool/"
response = requests.get(f"{self.url}{endpoint}{chain}/{address}/locks", headers=self._headers)
logger.debug(response.url)
return response.json()

def get_pools(self, chain, from_, to, order="asc", sort="creationTime", page=None, pageSize=None):
endpoint = "/pool/"
Expand Down Expand Up @@ -112,6 +118,12 @@ def get_token_price(self, chain, address):
logger.debug(response.url)
return response.json()

def get_token_audit(self, chain, address):
endpoint = "/token/"
response = requests.get(f"{self.url}{endpoint}{chain}/{address}/audit", headers=self._headers)
logger.debug(response.url)
return response.json()

def get_tokens(self, chain, from_, to, order="asc", sort="socialsInfoUpdated", page=None, pageSize=None):
endpoint = "/token/"
response = requests.get(self.url + endpoint + chain, params={"order": order, "sort": sort, "from": from_, "to": to, "page": page, "pageSize": pageSize}, headers=self._headers)
Expand Down
20 changes: 20 additions & 0 deletions examples/async_demov2.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ async def instance():
pool_price = await dextools.get_pool_price("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
pp.pprint(pool_price)

# Get pool locks
print("Get pool locks")
pool_locks = await dextools.get_pool_locks("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
pp.pprint(pool_locks)

# Get pools
print("Get pools")
pools = await dextools.get_pools("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
Expand Down Expand Up @@ -104,6 +109,11 @@ async def instance():
token_price = await dextools.get_token_price("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
pp.pprint(token_price)

# Get token audit
print("Get token audit")
token_audit = await dextools.get_token_audit("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
pp.pprint(token_audit)

# Get tokens
print("Get tokens")
tokens = await dextools.get_tokens("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
Expand Down Expand Up @@ -213,6 +223,11 @@ async def context_manager():
pool_price = await dextools.get_pool_price("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
pp.pprint(pool_price)

# Get pool locks
print("Get pool locks")
pool_locks = await dextools.get_pool_locks("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
pp.pprint(pool_locks)

# Get pools
print("Get pools")
pools = await dextools.get_pools("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
Expand Down Expand Up @@ -249,6 +264,11 @@ async def context_manager():
token_price = await dextools.get_token_price("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
pp.pprint(token_price)

# Get token audit
print("Get token audit")
token_audit = await dextools.get_token_audit("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
pp.pprint(token_audit)

# Get tokens
print("Get tokens")
tokens = await dextools.get_tokens("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
Expand Down
10 changes: 10 additions & 0 deletions examples/demov2.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
pool_price = dextools.get_pool_price("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
pp.pprint(pool_price)

# Get pool locks
print("Get pool locks")
pool_locks = dextools.get_pool_locks("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d")
pp.pprint(pool_locks)

# Get pools
print("Get pools")
pools = dextools.get_pools("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
Expand Down Expand Up @@ -102,6 +107,11 @@
token_price = dextools.get_token_price("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
pp.pprint(token_price)

# Get token audit
print("Get token audit")
token_audit = dextools.get_token_audit("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a")
pp.pprint(token_audit)

# Get tokens
print("Get tokens")
tokens = dextools.get_tokens("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dextools-python"
version = "0.3.1"
version = "0.3.2"
description = "A simple Python API wrapper for DEXTools"
repository = "https://github.com/alb2001/dextools-python"
authors = ["alb2001 <[email protected]>"]
Expand Down
20 changes: 20 additions & 0 deletions tests/test_async_dextools_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ async def test_get_pool_score(dextools_instance):
assert isinstance(response["data"]["votes"], dict)
assert isinstance(response["data"]["dextScore"], dict)

@pytest.mark.asyncio
async def test_get_pool_locks(dextools_instance):
chain = "ether"
pool = "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d"
response = await dextools_instance.get_pool_locks(chain, pool)

assert response["statusCode"] == 200
assert isinstance(response, dict)
assert isinstance(response["data"], dict)

@pytest.mark.asyncio
async def test_get_pool_price(dextools_instance):
chain = "ether"
Expand Down Expand Up @@ -187,6 +197,16 @@ async def test_get_token_price(dextools_instance):
assert isinstance(response, dict)
assert isinstance(response["data"], dict)

@pytest.mark.asyncio
async def test_get_token_audit(dextools_instance):
chain = "ether"
token = "0xfb7b4564402e5500db5bb6d63ae671302777c75a"
response = await dextools_instance.get_token_audit(chain, token)

assert response["statusCode"] == 200
assert isinstance(response, dict)
assert isinstance(response["data"], dict)

@pytest.mark.asyncio
async def test_get_tokens(dextools_instance):
chain = "ether"
Expand Down
18 changes: 18 additions & 0 deletions tests/test_dextools_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ def test_get_pool_score(dextools_instance):
assert isinstance(response["data"]["votes"], dict)
assert isinstance(response["data"]["dextScore"], dict)

def test_get_pool_locks(dextools_instance):
chain = "ether"
pool = "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d"
response = dextools_instance.get_pool_locks(chain, pool)

assert response["statusCode"] == 200
assert isinstance(response, dict)
assert isinstance(response["data"], dict)

def test_get_pool_price(dextools_instance):
chain = "ether"
pool = "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d"
Expand Down Expand Up @@ -170,6 +179,15 @@ def test_get_token_price(dextools_instance):
assert isinstance(response, dict)
assert isinstance(response["data"], dict)

def test_get_token_audit(dextools_instance):
chain = "ether"
token = "0xfb7b4564402e5500db5bb6d63ae671302777c75a"
response = dextools_instance.get_token_audit(chain, token)

assert response["statusCode"] == 200
assert isinstance(response, dict)
assert isinstance(response["data"], dict)

def test_get_tokens(dextools_instance):
chain = "ether"
from_ = "2023-11-14T19:00:00"
Expand Down

0 comments on commit 6587478

Please sign in to comment.