Skip to main content

Python3 Wrapper for CryptoCompare public API

Project description

https://img.shields.io/pypi/v/cryptocmp.svg https://img.shields.io/travis/OkThought/cryptocmp.svg Documentation Status Updates

Python wrapper for CryptoCompare API

Description

cryptocmp provides to the CryptoCompare API in two ways:

  • Straight wrappers of the API calls in cryptocmp.api package.

  • A more user friendly mapping to these wrappers in object-oriented style via the following classes:

    • cryptocmp.coin.Coin represents a crypto coin.

Installation

pip3 install cryptocmp

or this can also work if you have only python3 installed (the symlink pip pointing to pip3 is created)

pip install cryptocmp

Usage

Examples

In object-oriented style:

  • Get a set of all available crypto coins:

    >>> from cryptocmp.coin import Coin
    >>> Coin.all()
    {'EOSDAC', 'GAP', 'ARN', 'SERA', 'ICASH', 'STAR*', 'AC3', ...}
    
  • Get a current price of BTC in USD:

    >>> from cryptocmp.coin import Coin
    >>> bitcoin = Coin('BTC')
    >>> bitcoin.price('USD')
    6318.35``
    
  • Get a current price of BTC in USD, EUR and GBP at the same time (produces single API call under the hood):

    >>> from cryptocmp.coin import Coin
    >>> bitcoin = Coin('BTC')
    >>> bitcoin.price(('USD', 'EUR', 'GBP'))
    {'USD': 6316.17, 'EUR': 5540.34, 'GBP': 4977.23}``
    
  • Get last 2 candles of BTC/USD daily historical data:

    >>> CoinPair('BTC', 'USD').price_history(points_num=2)
    [
        {
            'time': 1534291200,
            'close': 6274.22,
            'high': 6620.07,
            'low': 6193.63,
            'open': 6199.63,
            'volumefrom': 132926.33,
            'volumeto': 852103141.83
        },
        {
            'time': 1534377600,
            'close': 6439.39,
            'high': 6439.39,
            'low': 6217.33,
            'open': 6274.22,
            'volumefrom': 24013.18,
            'volumeto': 152446768.26
        }
    ]

Credit

Thanks to CryptoCompare for providing this service and building a nice community around everything crypto related.

Project was partially patched with files generated by Cookiecutter using cookiecutter-pypackage project template. Thanks to Audrey Roy Greenfeld and contributors who made python package creation so easy.

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

cryptocmp-0.3.3.tar.gz (16.5 kB view hashes)

Uploaded Source

Built Distribution

cryptocmp-0.3.3-py2.py3-none-any.whl (17.8 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