Python wraper for bitquery.io DEX API
Project description
dexapi
Python wrapper for bitquery.io DEX API
Installation
Install the latest version from PyPI is by using pip:
pip install dexapi
Alternatively, install directly from the GitHub repository:
pip install git+https://github.com/kayrauygun/dexapi.git
Functions
Create dexAPI
object using following code:
import dexapi
api = dexapi.dexAPI("API_KEY", network="NETWORK_NAME")
Available networks are "ethereum" and "bsc".
List of Exchanges
get_exchanges
function returns DEXs with highest volume (in USD) in network between two datetimes.
dexapi.dexAPI.get_exchanges(start_time, end_time, limit)
start_time
: str | datetime, optional, default = first day of current year, format = "YYYY-MM-DD",
datetime.date(YYYY,MM,DD), "YYYY-MM-DDTHH:MM:SS" (ISO8601DateTime), datetime.datetime(YYYY,MM,DD,HH,MM,SS),
if hours, minutes, seconds are not specified it will be taken as 00:00:00
end_time
: str | datetime, optional, default = now, format = "YYYY-MM-DD",
datetime.date(YYYY,MM,DD), "YYYY-MM-DDTHH:MM:SS" (ISO8601DateTime), datetime.datetime(YYYY,MM,DD,HH,MM,SS),
if hours, minutes, seconds are not specified it will be taken as 23:59:59
limit
: int, optional, default = 20, maximum number of entries function returns
return
:* dataframe, columns = [
"exchange": DEX name,
"protocol": protocol DEX uses,
"count": number of trades,
"tradeAmount": total volume in USD,
"exchangeAddress": address of exchange on network
]*
Example usage:
import dexapi
api = dexapi.dexAPI("API_KEY", network="ethereum")
api.get_exchanges("2022-03-01", "2022-03-15", 20 )
List of Pairs
get_pairs
function returns pairs with highest volume (in USD) in the DEX between two datetimes.
dexapi.dexAPI.get_pairs(exchange_address, start_time, end_time, limit)
exchange_address
: str, address of exchange on network
start_time
: str | datetime, optional, default = first day of current year, format = "YYYY-MM-DD",
datetime.date(YYYY,MM,DD), "YYYY-MM-DDTHH:MM:SS" (ISO8601DateTime), datetime.datetime(YYYY,MM,DD,HH,MM,SS),
if hours, minutes, seconds are not specified it will be taken as 00:00:00
end_time
: str | datetime, optional, default = now, format = "YYYY-MM-DD",
datetime.date(YYYY,MM,DD), "YYYY-MM-DDTHH:MM:SS" (ISO8601DateTime), datetime.datetime(YYYY,MM,DD,HH,MM,SS),
if hours, minutes, seconds are not specified it will be taken as 23:59:59
limit
: int, optional, default = 20, maximum number of entries function returns
return
: dataframe, columns = [
"exchange": DEX name,
"protocol": protocol DEX uses,
"currency1": first leg of swaps,
"currency2": second leg of swap,
"smartContract": address of smart contract trades pair on network
]
Example usage:
import dexapi
api = dexapi.dexAPI("API_KEY", network="ethereum")
api.get_exchanges("0x1f98431c8ad98523631ae4a59f267346ea31f984", "2022-03-01", "2022-03-15", 50 )
List of Trades
get_trades
function returns most recent trades use the smart contract between two times.
dexapi.dexAPI.get_trades(smart_contract, start_time, end_time, limit)
smart_contract
: str, address of smart contract on network
start_time
: str | datetime, optional, default = today 00:00:00, format = "YYYY-MM-DD",
datetime.date(YYYY,MM,DD), "YYYY-MM-DDTHH:MM:SS" (ISO8601DateTime), datetime.datetime(YYYY,MM,DD,HH,MM,SS),
if hours, minutes, seconds are not specified it will be taken as 00:00:00
end_time
: str | datetime, optional, default = now, format = "YYYY-MM-DD",
datetime.date(YYYY,MM,DD), "YYYY-MM-DDTHH:MM:SS" (ISO8601DateTime), datetime.datetime(YYYY,MM,DD,HH,MM,SS),
if hours, minutes, seconds are not specified it will be taken as 23:59:59
limit
: int, optional, default = 1000, maximum number of entries function returns
return
: dataframe, columns = [
"exchange": DEX name,
"protocol": protocol DEX uses,
"timestamp": timestamp of block,
"block": block height,
"buyCurrency": currency DEX buys,
"sellCurrency": currency DEX sells,
"price": price of "buyCurrency" in terms of "sellCurrency",
"tradeAmount": volume in USD
"transaction": transaction hash
]
Example usage:
import dexapi
api = dexapi.dexAPI("API_KEY", network="ethereum")
api.get_trades("0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640", "2022-03-15", "2022-03-15", 1500 )
Historical Balance
get_balances
function returns the balance of the smart contract address at a specific time.
dexapi.dexAPI.get_balances(address, time)
address
: *str, address of the smart contract on network
time
: str | datetime, optional, default = now, format = "YYYY-MM-DD",
datetime.date(YYYY,MM,DD), "YYYY-MM-DDTHH:MM:SS" (ISO8601DateTime), datetime.datetime(YYYY,MM,DD,HH,MM,SS),
if hours, minutes, seconds are not specified it will be taken as 23:59:59
return
: dataframe, columns = [
"currency": currency symbol,
"value": number of tokens owned by address,
"currencyAddress": address of currency,
]
Example usage:
import dexapi
api = dexapi.dexAPI("API_KEY", network="ethereum")
api.get_trades("0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640", "2022-03-15T14:55:55")
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
File details
Details for the file dexapi-0.1.2.tar.gz
.
File metadata
- Download URL: dexapi-0.1.2.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.50.2 importlib-metadata/4.11.3 keyring/21.4.0 rfc3986/1.4.0 colorama/0.4.4 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9441a3173cc0b21bbc436ef8295a4f7ade63439846294de847d18bd2b3eccef |
|
MD5 | 7c36be3a3b25a4c07b49f10ab6bcead7 |
|
BLAKE2b-256 | 0cf4df15d00d3eb97f00f9528f232f8b5ba0d84074320fde1b29003baa6c25df |