SkillAgentSearch skills...

Cryptocompy

Simple Python 3 wrapper for the public CryptoCompare API.

Install / Use

/learn @ttsteiger/Cryptocompy
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

cryptocompy

Simple wrapper for the public CryptoCompare API.

Cryptocompare API: https://www.cryptocompare.com/api

Table of Contents

ToDo:

  • add all get functions

  • complete docstrings

  • error handling for http requests

  • throw warnings for conversions

  • add toTs parameter to price functions

  • improve date handling in historical price functions

  • add folder with some more complex example code (for eg. compare average mining equipment prices graphically)

  • both mining contracts and equipment calls return same message -> tell CC Support?

  • installation through pip does not install requests qutomatically

Installation

pip install cryptocompy

Code of Conduct

Dont abuse wrapper to spam the Cryptocompare API. A request every 10 seconds should be more than enough.

Contributing

If you would like to help me with my work or have any suggestions for improvements please follow the "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull request so that we can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a pull request!

Documentation

coin.py

To access these functions, you can import them in the following way:

from cryptocompy import coin

get_coin_list

get_coin_list(coins='all')

Get general information about all the coins available on cryptocompare.com.

Arguments:

coins: Default value of 'all' returns information about all the coins available on the site. Otherwise a single string or list of coin symbols can be used.

Returns:

The function returns a dictionairy containing individual dictionairies for the coins specified by the input. The key of the top dictionary corresponds to the coin symbol. The dictionary returned has the following structure:

{coin_symbol1: {'Algorithm' : ...,
                'CoinName': ...,
                'FullName': ...,
                'FullyPremined': ...,
                'Id': ...,
                'ImageUrl': ...,
                'Name': ...,
                'PreMinedValue': ...,
                'ProofType': ...,
                'SortOrder': ...,
                'TotalCoinsFreeFloat': ...,
                'TotalCoinSupply': ...,
			    'Url': ...},
 coin_symbol2: {...},
 ...}

Example 1:

Get general coin information for Bitcoin and Ethereum.

coin.get_coin_list(coins=["BTC", "ETH"])
{'BTC': {'Algorithm': 'SHA256',
  'CoinName': 'Bitcoin',
  'FullName': 'Bitcoin (BTC)',
  'FullyPremined': '0',
  'Id': '1182',
  'ImageUrl': '/media/19633/btc.png',
  'Name': 'BTC',
  'PreMinedValue': 'N/A',
  'ProofType': 'PoW',
  'SortOrder': '1',
  'TotalCoinSupply': '21000000',
  'TotalCoinsFreeFloat': 'N/A',
  'Url': '/coins/btc/overview'},
 'ETH': {'Algorithm': 'Ethash',
  'CoinName': 'Ethereum ',
  'FullName': 'Ethereum  (ETH)',
  'FullyPremined': '0',
  'Id': '7605',
  'ImageUrl': '/media/20646/eth.png',
  'Name': 'ETH',
  'PreMinedValue': 'N/A',
  'ProofType': 'PoW',
  'SortOrder': '2',
  'TotalCoinSupply': '0',
  'TotalCoinsFreeFloat': 'N/A',
  'Url': '/coins/eth/overview'}}

Example 2:

Return information for all the coins available on Cryptocompare and print out ten of their symbols.

coin_data = coin.get_coin_list()
symbols = list(coin_data.keys())[:10]
symbols
['BOSS', 'EOS', 'CHC', 'GAY', 'APT', 'DEEP', 'SCOT', 'HUGE', 'NXS', 'GCR']

get_coin_snapshot

get_coin_snapshot(fsym, tsym)

Get blockchain information, aggregated data as well as data for the individual exchanges available for the specified currency pair.

Arguments:

  • fsym: FROM symbol.
  • tsym: TO symbol. Blockchain information will only be returned if this parameter is a fiat currency.

Returns:

The function returns a dictionairy containing blockain as well as trading information from the different exchanges were the specified currency pair is available.

{'AggregatedData': dict,
 'Algorithm': ...,
 'BlockNumber': ...,
 'BlockReward': ...,
 'Exchanges': [dict1, dict2, ...],
 'NetHashesPerSecond': ...,
 'ProofType': ...,
 'TotalCoinsMined': ...}
 
dict = {'FLAGS': ...,
        'FROMSYMBOL': ...,
        'HIGH24HOUR': ...,
        'LASTMARKET': ...,
        'LASTTRADEID': ...,
        'LASTUPDATE': ...,
        'LASTVOLUME': ...,
        'LASTVOLUMETO': ...,
        'LOW24HOUR': ...,
        'MARKET': ...,
        'OPEN24HOUR': ...,
        'PRICE': ...,
        'TOSYMBOL': ...,
        'TYPE': ...,
        'VOLUME24HOUR': ...,
        'VOLUME24HOURTO': ...}

Example 1:

Get all the exchanges were the LTC/EUR currency pair is available for trading.

coin_data = coin.get_coin_snapshot("LTC", "EUR")
exchanges = [e['MARKET'] for e in coin_data['Exchanges']]
exchanges
['BitSquare',
 'Tidex',
 'HitBTC',
 'Kraken',
 'CCEDK',
 'Yacuna',
 'BTCE',
 'TheRockTrading',
 'Bitstamp',
 'Cexio',
 'Exmo',
 'BitBay',
 'Coinbase']

Example 2:

Get the aggregated trading volume across all the available exchanges for the NEO/BTC pair.

coin_data = coin.get_coin_snapshot("NEO", "BTC")
volume = float(coin_data['AggregatedData']['VOLUME24HOUR'])
volume
2402094.313135109

price.py

To access these functions, you can import them in the following way:

from cryptocompy import price

get_current_price

get_current_price(fsyms, tsyms, e='all', try_conversion=True, full=False, format='raw')

Get latest trading price or full trading information in display or raw format for the specified FROM/TO currency pairs.

Arguments:

  • fsyms: Single string or list of FROM symbols.
  • tsyms: Single string or list of TO symbols.
  • e: Default returns average price across all exchanges. Can be set to the name of a single exchange.
  • try_conversion: If the crypto does not trade directly into the toSymbol requested, BTC will be used for conversion. If set to false, it will try to get values without using any conversion at all.
  • full: Default of False returns only the latest price.
  • format: Default returns the 'RAW' format. Can be changed to 'DISPLAY' format.

Returns:

Returns a dictionary containing the latest price pairs if full is set to false:

{fsym1: {tsym1: ..., tsym2:..., ...},
 fsym2: {...},
 ...}

or full trading info dictionaries for all the price pairs in the other case:

{fsym1: {tsym1: {'CHANGE24HOUR': ...,
                 'CHANGEPCT24HOUR': ...,
                 'FLAGS': ...,
                 'FROMSYMBOL': ...,
                 'HIGH24HOUR': ...,
                 'LASTMARKET': ...,
                 'LASTTRADEID': ...,
                 'LASTUPDATE': ..., 
                 'LASTVOLUME': ...,
                 'LASTVOLUMETO': ...,
                 'LOW24HOUR': ...,
                 'MARKET' ...,
                 'MKTCAP': ...,
                 'OPEN24HOUR': ...,
                 'PRICE': ...,
                 'SUPPLY': ...,
                 'TOSYMBOL': ...,
                 'TYPE': ..., 
                 'VOLUME24HOUR': ...,
                 'VOLUME24HOURTO': ...},
         tsym2: ..., ...},
fsym2: {...},
...}

Example 1:

Get the current BTC prices averaged across all exchanges in EUR, USD and ETH.

price.get_current_price("BTC", ["EUR", "USD", "ETH"])
{'BTC': {'ETH': 13.49, 'EUR': 3361.68, 'USD': 3962.38}}

Example 2:

Get the current BTC and ETH prices in EUR and USD.

price.get_current_price(["ETH", "BTC"], ["EUR", "USD"])
{'BTC': {'EUR': 3361.62, 'USD': 3962.16},
 'ETH': {'EUR': 248.04, 'USD': 293.32}}

Example 3:

Get the current ETH trading price in EUR from Kraken.

price.get_current_price("ETH", "EUR", e="Kraken")
{'ETH': {'EUR': 247.78}}

Example 4:

Get the current trading information about the ETH/EUR and ETH/BTC markets.

price.get_current_price("ETH", ["EUR", "BTC"], full=True)
{'ETH': {'BTC': {'CHANGE24HOUR': -0.002250000000000002,
   'CHANGEPCT24HOUR': -2.945411703102503,
   'FLAGS': '4',
   'FROMSYMBOL': 'ETH',
   'HIGH24HOUR': 0.07657,
   'LASTMARKET': 'HitBTC',
   'LASTTRADEID': 39464478,
   'LASTUPDATE': 1506430531,
   'LASTVOLUME': 1.168,
   'LASTVOLUMETO': 0.08631987199999999,
   'LOW24HOUR': 0.07397,
   'MARKET': 'CCCAGG',
   'MKTCAP': 7030474.546815192,
   'OPEN24HOUR': 0.07639,
   'PRICE': 0.07414,
   'SUPPLY': 94827010.3428,
   'TOSYMBOL': 'BTC',
   'TYPE': '5',
   'VOLUME24HOUR': 304207.36878715,
   'VOLUME24HOURTO': 22841.949823297473},
  'EUR': {'CHANGE24HOUR': 4.6200000000000045,
   'CHANGEPCT24HOUR': 1.8977982254354275,
   'FLAGS': '4',
   'FROMSYMBOL': 'ETH',
   'HIGH24HOUR': 251.35,
   'LASTMARKET': 'Kraken',
   'LASTTRADEID': 1506430533.8385,
   'LASTUPDATE': 1506430533,
   'LASTVOLUME': 2,
   'LASTVOLUMETO': 495.6,
   

Related Skills

View on GitHub
GitHub Stars81
CategoryDevelopment
Updated5d ago
Forks33

Languages

Python

Security Score

100/100

Audited on Apr 2, 2026

No findings