Skip to main content

cryptologic

GitHub Workflow Status (branch) Coverage Status PyPI - Python Version PyPI version

Python3 wrapper to query cryptocurrency prices (and more) using the CryptoCompare API.

Install

pip install cryptologic

Usage

import cryptologic

API Key

If you have an API key, you can either set it as environment variable CRYPTOCOMPARE_API_KEY or set it manually with:

cryptologic.cryptologic._set_api_key_parameter(KEY_HERE)

Coin List

cryptologic.coin_list(format=False)
# ...
# },
# 'BTC': {
#  'Id': '1182'
#  'Url': '/coins/btc/overview'
#  'ImageUrl': '/media/19633/btc.png'
#  'Name': 'BTC'
#  'CoinName': 'Bitcoin'
#  'FullName': 'Bitcoin (BTC)'
#  'Algorithm': 'SHA256'
#  'ProofType': 'PoW'
#  'FullyPremined': '0'
#  'TotalCoinSupply': '21000000'
#  'PreMinedValue': 'N/A'
#  'TotalCoinsFreeFloat': 'N/A'
#  'SortOrder': '1'
# },
# ...

If format is True, the coin list is returned as Python list, containing only the abbreviations (like BTC).

Price

cryptologic.get_price('BTC')
# or
cryptologic.get_price('BTC', currency='USD', full=True)
# or
cryptologic.get_price(['BTC', 'ETH'], ['EUR', 'GBP'])

# {'BTC': {'EUR': 3709.04, 'GBP': 3354.78},
#  'ETH': {'EUR': 258.1, 'GBP': 241.25}}

Historical Prices

# pass either datetime or time instance
cryptologic.price('XMR', timestamp=datetime.datetime(2017,6,6), exchange='CCCAGG')
# or
cryptologic.price('XMR', 'EUR', datetime.datetime(2017,6,6))

# {'XMR': {'EUR': 43.05}}

Day

cryptologic.price_day('BTC', currency='EUR')
cryptologic.price_day('BTC', currency='EUR', limit=30)
cryptologic.price_day('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(2019,6,6))
# or
cryptologic.price_day('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(1559815200))

Hour

cryptologic.price_hour('BTC', currency='USD')
cryptologic.price_hour('BTC', currency='EUR', limit=24)
cryptologic.price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG')
cryptologic.price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(2019,6,6,12))
# or
cryptologic.price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(1559815200))

Minute

cryptologic.price_minute('BTC', currency='EUR')
cryptologic.price_minute('BTC', currency='EUR', limit=1440)
cryptologic.price_minute('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime.now())

Average

cryptologic.get_average('BTC', currency='EUR', exchange='Kraken')
# {
# 'MARKET': 'CUSTOMAGG',
# 'FROMSYMBOL': 'BTC',
# 'TOSYMBOL': 'EUR',
# 'FLAGS': 0,
# 'PRICE': 3610,
# 'LASTUPDATE': 1503066719,
# 'LASTVOLUME': 0.5,
# 'LASTVOLUMETO': 1805,
# 'LASTTRADEID': 1503066719.7584,
# 'VOLUME24HOUR': 12614.509997469995,
# 'VOLUME24HOURTO': 46397723.00499387,
# 'OPEN24HOUR': 3847.9,
# 'HIGH24HOUR': 3848.96,
# 'LOW24HOUR': 3555,
# 'LASTMARKET': 'Kraken',
# 'CHANGE24HOUR': -237.9000000000001,
# 'CHANGEPCT24HOUR': -6.182593102731363
# }

Exchanges

cryptologic.get_exchanges()

Pairs

cryptologic.get_pairs()
pairs = cryptologic.get_pairs(exchange='Kraken')

Developing

Tests run assuming you have an API key, otherwise they will error due to rate limiting. Install the dev dependencies and run the tests:

pip3 install -r requirements.txt
python3 -m pytest

Credit

Metadata

Release files for cryptologic 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cryptologic 1.0.2
File Size Uploaded Provenance
cryptologic-1.0.2.tar.gz 8.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cryptologic 1.0.2
File Interpreter ABI Platform
cryptologic-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / cryptologic-1.0.2.tar.gz

Download URL cryptologic-1.0.2.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
da410d5418bad76e35b9253273d4a153086dda45265adf96b092d024c6da161e
BLAKE2b-256 checksum
How to use checksums
f1914dd8ffd083a5a85eb0b6dc2ddf17d2ec7173422a98ffef169f4d57cbf0d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.24.0

Release files / cryptologic-1.0.2-py3-none-any.whl

Download URL cryptologic-1.0.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4533b96cd9465205d3f72e8aa9d13e78e7b19b94e369cb767893b8011fcc6354
BLAKE2b-256 checksum
How to use checksums
e86b48a12725f846dfb6aae3fb7dfc894c37f7f921d35bfb6707535ffaaef53f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.24.0

Security for cryptologic 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page