GithubHelp home page GithubHelp logo

dexapi's Introduction

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 the 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 the 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")

dexapi's People

Contributors

kayrauygun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.