A simple request wrapper for the Pancake-Swap API.
Install package
# Using pip
$ pip install pythonpancakes
# Or from source
$ git clone https://github.com/scottburlovich/pythonpancakes.git pythonpancakes
$ cd pythonpancakes
$ python3 setup.py installImport module into your project and initialize API class
frompythonpancakesimportPancakeSwapAPIps=PancakeSwapAPI()Please note, the API functionality currently exposed by PancakeSwap is quite basic. This package will be updated as they add new functionality.
Returns a dictionary containing data for the top ~1000 PancakeSwap pairs, sorted by reserves.
Example invocation:
summary=ps.summary()Example output:
# output:
{
"updated_at": 1234567, //UNIXtimestamp"data": {
"0x..._0x...": { //BEP20tokenaddresses, joinedbyanunderscore"price": "...", //pricedenominatedintoken1/token0"base_volume": "...", //last24hvolumedenominatedintoken0"quote_volume": "...", //last24hvolumedenominatedintoken1"liquidity": "...", //liquiditydenominatedinUSD"liquidity_BNB": "..."//liquiditydenominatedinBNB
},
// ...
}
}If address parameter is specified, returns the token information, based on address. Otherwise, returns the tokens in the top ~1000 pairs on PancakeSwap, sorted by reserves.
Example invocation without address:
tokens=ps.tokens()Example output without address:
{
"updated_at": 1234567, //UNIXtimestamp"data": {
"0x...": { //theaddressoftheBEP20token"name": "...", //notnecessarilyincludedforBEP20tokens"symbol": "...", //notnecessarilyincludedforBEP20tokens"price": "...", //pricedenominatedinUSD"price_BNB": "...", //pricedenominatedinBNB
},
// ...
}
}Example invocation with address:
token=ps.tokens('0x00000000000...')Example output with address:
# output
{
"updated_at": 1234567, //UNIXtimestamp"data": {
"name": "...", //notnecessarilyincludedforBEP20tokens"symbol": "...", //notnecessarilyincludedforBEP20tokens"price": "...", //pricedenominatedinUSD"price_BNB": "...", //pricedenominatedinBNB
}
}Returns data for the top ~1000 PancakeSwap pairs, sorted by reserves.
Example invocation:
pairs=ps.pairs()Example output
{
"updated_at": 1234567, //UNIXtimestamp"data": {
"0x..._0x...": { //theassetidsofBNBandBEP20tokens, joinedbyanunderscore"pair_address": "0x...", //pairaddress"base_name": "...", //token0name"base_symbol": "...", //token0symbol"base_address": "0x...", //token0address"quote_name": "...", //token1name"quote_symbol": "...", //token1symbol"quote_address": "0x...", //token1address"price": "...", //pricedenominatedintoken1/token0"base_volume": "...", //volumedenominatedintoken0"quote_volume": "...", //volumedenominatedintoken1"liquidity": "...", //liquiditydenominatedinUSD"liquidity_BNB": "..."//liquiditydenominatedinBNB
},
// ...
}
}