Skip to main content

A basic request wrapper for the PancakeSwap API

Project description

🐍 Python Pancakes 🥞

A simple request wrapper for the Pancake-Swap API.

Installation

Install package

# Using pip
$ pip install pythonpancakes

# Or from source
$ git clone https://github.com/scottburlovich/pythonpancakes.git pythonpancakes
$ cd pythonpancakes
$ python3 setup.py install

Import module into your project and initialize API class

from pythonpancakes import PancakeSwapAPI
ps = PancakeSwapAPI()

Usage

Please note, the API functionality currently exposed by PancakeSwap is quite basic. This package will be updated as they add new functionality.

summary()

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,              // UNIX timestamp
  "data": {
    "0x..._0x...": {                  // BEP20 token addresses, joined by an underscore
      "price": "...",                 // price denominated in token1/token0
      "base_volume": "...",           // last 24h volume denominated in token0
      "quote_volume": "...",          // last 24h volume denominated in token1
      "liquidity": "...",             // liquidity denominated in USD
      "liquidity_BNB": "..."          // liquidity denominated in BNB
    },
    // ...
  }
}

tokens(address)

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,              // UNIX timestamp
  "data": {
    "0x...": {                        // the address of the BEP20 token
      "name": "...",                  // not necessarily included for BEP20 tokens
      "symbol": "...",                // not necessarily included for BEP20 tokens
      "price": "...",                 // price denominated in USD
      "price_BNB": "...",             // price denominated in BNB
    },
    // ...
  }
}

Example invocation with address:

token = ps.tokens('0x00000000000...')

Example output with address:

# output
{
  "updated_at": 1234567,              // UNIX timestamp
  "data": {
    "name": "...",                    // not necessarily included for BEP20 tokens
    "symbol": "...",                  // not necessarily included for BEP20 tokens
    "price": "...",                   // price denominated in USD
    "price_BNB": "...",               // price denominated in BNB
  }
}

pairs()

Returns data for the top ~1000 PancakeSwap pairs, sorted by reserves.

Example invocation:

pairs = ps.pairs()

Example output

{
  "updated_at": 1234567,              // UNIX timestamp
  "data": {
    "0x..._0x...": {                  // the asset ids of BNB and BEP20 tokens, joined by an underscore
      "pair_address": "0x...",        // pair address
      "base_name": "...",             // token0 name
      "base_symbol": "...",           // token0 symbol
      "base_address": "0x...",        // token0 address
      "quote_name": "...",            // token1 name
      "quote_symbol": "...",          // token1 symbol
      "quote_address": "0x...",       // token1 address
      "price": "...",                 // price denominated in token1/token0
      "base_volume": "...",           // volume denominated in token0
      "quote_volume": "...",          // volume denominated in token1
      "liquidity": "...",             // liquidity denominated in USD
      "liquidity_BNB": "..."          // liquidity denominated in BNB
    },
    // ...
  }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pythonpancakes-1.0.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

pythonpancakes-1.0.1-py2.py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page