# cryptocompare [![Test](https://github.com/lagerfeuer/cryptocompare/actions/workflows/test.yml/badge.svg)](https://github.com/lagerfeuer/cryptocompare/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/lagerfeuer/cryptocompare/badge.svg?branch=master)](https://coveralls.io/github/lagerfeuer/cryptocompare?branch=master) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cryptocompare) [![PyPI version](https://badge.fury.io/py/cryptocompare.svg)](https://badge.fury.io/py/cryptocompare)
Python3 wrapper to query cryptocurrency prices (and more) using the [CryptoCompare](https://min-api.cryptocompare.com/) API.
## Install
```sh
pip3 install cryptocompare
```
## Usage
```python
import cryptocompare
```
## API Key
If you have an API key, you can either set it as environment variable `CRYPTOCOMPARE_API_KEY` or set it manually with:
```
cryptocompare.cryptocompare._set_api_key_parameter(KEY_HERE)
```
### Coin List
```python
cryptocompare.get_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
```python
cryptocompare.get_price('BTC')
# or
cryptocompare.get_price('BTC', currency='USD', full=True)
# or
cryptocompare.get_price(['BTC', 'ETH'], ['EUR', 'GBP'])
# {'BTC': {'EUR': 3709.04, 'GBP': 3354.78},
# 'ETH': {'EUR': 258.1, 'GBP': 241.25}}
```
### Historical Prices
```python
# pass either datetime or time instance
cryptocompare.get_historical_price('XMR', timestamp=datetime.datetime(2017,6,6), exchange='CCCAGG')
# or
cryptocompare.get_historical_price('XMR', 'EUR', datetime.datetime(2017,6,6))
# {'XMR': {'EUR': 43.05}}
```
#### Day
```python
cryptocompare.get_historical_price_day('BTC', currency='EUR')
cryptocompare.get_historical_price_day('BTC', currency='EUR', limit=30)
cryptocompare.get_historical_price_day('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(2019,6,6))
# or
cryptocompare.get_historical_price_day('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(1559815200))
```
#### Hour
```python
cryptocompare.get_historical_price_hour('BTC', currency='EUR')
cryptocompare.get_historical_price_hour('BTC', currency='EUR', limit=24)
cryptocompare.get_historical_price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG')
cryptocompare.get_historical_price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(2019,6,6,12))
# or
cryptocompare.get_historical_price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(1559815200))
```
#### Minute
```python
cryptocompare.get_historical_price_minute('BTC', currency='EUR')
cryptocompare.get_historical_price_minute('BTC', currency='EUR', limit=1440)
cryptocompare.get_historical_price_minute('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime.now())
```
### Average
```python
cryptocompare.get_avg('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
```python
cryptocompare.get_exchanges()
```
### Pairs
```python
cryptocompare.get_pairs()
pairs = cryptocompare.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:
```sh
pip3 install -r requirements.txt
python3 -m pytest
```
## Credit
* The [CryptoCompare API](https://min-api.cryptocompare.com/).
## Disclaimer
This is a hobby project, no guarantees.
If you find bugs or want additional features,
open an issue and/or create a pull request.
Raw data
{
"_id": null,
"home_page": "https://github.com/LambertoKalisto/CryptoCompare",
"name": "cryptocompare-fields",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": null,
"keywords": "crypto cryptocurrency wrapper cryptocompare",
"author": "lamberto",
"author_email": "dhgdgjdjhd@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/43/6a/a5ba21849a53cdd34d154f20e0cb40f1adda0e182ddeacb7f57bc5f9ae08/cryptocompare_fields-0.1.1.tar.gz",
"platform": null,
"description": "# cryptocompare [![Test](https://github.com/lagerfeuer/cryptocompare/actions/workflows/test.yml/badge.svg)](https://github.com/lagerfeuer/cryptocompare/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/lagerfeuer/cryptocompare/badge.svg?branch=master)](https://coveralls.io/github/lagerfeuer/cryptocompare?branch=master) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cryptocompare) [![PyPI version](https://badge.fury.io/py/cryptocompare.svg)](https://badge.fury.io/py/cryptocompare)\r\n\r\n\r\nPython3 wrapper to query cryptocurrency prices (and more) using the [CryptoCompare](https://min-api.cryptocompare.com/) API.\r\n\r\n\r\n## Install\r\n```sh\r\npip3 install cryptocompare\r\n```\r\n\r\n## Usage\r\n\r\n```python\r\nimport cryptocompare\r\n```\r\n\r\n## API Key\r\n\r\nIf you have an API key, you can either set it as environment variable `CRYPTOCOMPARE_API_KEY` or set it manually with: \r\n\r\n```\r\ncryptocompare.cryptocompare._set_api_key_parameter(KEY_HERE)\r\n```\r\n\r\n### Coin List\r\n\r\n```python\r\ncryptocompare.get_coin_list(format=False)\r\n# ...\r\n# },\r\n# 'BTC': {\r\n# 'Id': '1182'\r\n# 'Url': '/coins/btc/overview'\r\n# 'ImageUrl': '/media/19633/btc.png'\r\n# 'Name': 'BTC'\r\n# 'CoinName': 'Bitcoin'\r\n# 'FullName': 'Bitcoin (BTC)'\r\n# 'Algorithm': 'SHA256'\r\n# 'ProofType': 'PoW'\r\n# 'FullyPremined': '0'\r\n# 'TotalCoinSupply': '21000000'\r\n# 'PreMinedValue': 'N/A'\r\n# 'TotalCoinsFreeFloat': 'N/A'\r\n# 'SortOrder': '1'\r\n# },\r\n# ...\r\n```\r\n\r\nIf `format` is `True`, the coin list is returned as Python list,\r\ncontaining only the abbreviations (like `BTC`).\r\n\r\n### Price\r\n\r\n```python\r\ncryptocompare.get_price('BTC')\r\n# or\r\ncryptocompare.get_price('BTC', currency='USD', full=True)\r\n# or\r\ncryptocompare.get_price(['BTC', 'ETH'], ['EUR', 'GBP'])\r\n\r\n# {'BTC': {'EUR': 3709.04, 'GBP': 3354.78},\r\n# 'ETH': {'EUR': 258.1, 'GBP': 241.25}}\r\n```\r\n\r\n### Historical Prices\r\n\r\n```python\r\n# pass either datetime or time instance\r\ncryptocompare.get_historical_price('XMR', timestamp=datetime.datetime(2017,6,6), exchange='CCCAGG')\r\n# or\r\ncryptocompare.get_historical_price('XMR', 'EUR', datetime.datetime(2017,6,6))\r\n\r\n# {'XMR': {'EUR': 43.05}}\r\n```\r\n\r\n#### Day\r\n\r\n```python\r\ncryptocompare.get_historical_price_day('BTC', currency='EUR')\r\ncryptocompare.get_historical_price_day('BTC', currency='EUR', limit=30)\r\ncryptocompare.get_historical_price_day('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(2019,6,6))\r\n# or\r\ncryptocompare.get_historical_price_day('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(1559815200))\r\n```\r\n\r\n#### Hour\r\n\r\n```python\r\ncryptocompare.get_historical_price_hour('BTC', currency='EUR')\r\ncryptocompare.get_historical_price_hour('BTC', currency='EUR', limit=24)\r\ncryptocompare.get_historical_price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG')\r\ncryptocompare.get_historical_price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(2019,6,6,12))\r\n# or\r\ncryptocompare.get_historical_price_hour('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime(1559815200))\r\n```\r\n\r\n#### Minute\r\n\r\n```python\r\ncryptocompare.get_historical_price_minute('BTC', currency='EUR')\r\ncryptocompare.get_historical_price_minute('BTC', currency='EUR', limit=1440)\r\ncryptocompare.get_historical_price_minute('BTC', 'EUR', limit=24, exchange='CCCAGG', toTs=datetime.datetime.now())\r\n```\r\n\r\n### Average\r\n\r\n```python\r\ncryptocompare.get_avg('BTC', currency='EUR', exchange='Kraken')\r\n# {\r\n# 'MARKET': 'CUSTOMAGG',\r\n# 'FROMSYMBOL': 'BTC',\r\n# 'TOSYMBOL': 'EUR',\r\n# 'FLAGS': 0,\r\n# 'PRICE': 3610,\r\n# 'LASTUPDATE': 1503066719,\r\n# 'LASTVOLUME': 0.5,\r\n# 'LASTVOLUMETO': 1805,\r\n# 'LASTTRADEID': 1503066719.7584,\r\n# 'VOLUME24HOUR': 12614.509997469995,\r\n# 'VOLUME24HOURTO': 46397723.00499387,\r\n# 'OPEN24HOUR': 3847.9,\r\n# 'HIGH24HOUR': 3848.96,\r\n# 'LOW24HOUR': 3555,\r\n# 'LASTMARKET': 'Kraken',\r\n# 'CHANGE24HOUR': -237.9000000000001,\r\n# 'CHANGEPCT24HOUR': -6.182593102731363\r\n# }\r\n```\r\n\r\n### Exchanges\r\n\r\n```python\r\ncryptocompare.get_exchanges()\r\n```\r\n\r\n### Pairs\r\n\r\n```python\r\ncryptocompare.get_pairs()\r\npairs = cryptocompare.get_pairs(exchange='Kraken')\r\n```\r\n\r\n## Developing\r\n\r\nTests run assuming you have an API key, otherwise they will error due to rate limiting. Install the dev dependencies and run the tests:\r\n```sh\r\npip3 install -r requirements.txt\r\npython3 -m pytest\r\n```\r\n\r\n## Credit\r\n\r\n* The [CryptoCompare API](https://min-api.cryptocompare.com/).\r\n\r\n## Disclaimer\r\n\r\nThis is a hobby project, no guarantees.\r\nIf you find bugs or want additional features,\r\nopen an issue and/or create a pull request.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Wrapper for CryptoCompare.com",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/LambertoKalisto/CryptoCompare"
},
"split_keywords": [
"crypto",
"cryptocurrency",
"wrapper",
"cryptocompare"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "aa0e8c79c2f4dd17439f250778f0f34e404994bc9bcd310cf9793b8c4f8b22dd",
"md5": "b9b885e2b6782d508253b2fc7cf68c24",
"sha256": "690d60a358b06628d85844a7248e7e185f50e2294d2dd817d693639f94656758"
},
"downloads": -1,
"filename": "cryptocompare_fields-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b9b885e2b6782d508253b2fc7cf68c24",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 6735,
"upload_time": "2024-04-29T07:35:01",
"upload_time_iso_8601": "2024-04-29T07:35:01.991055Z",
"url": "https://files.pythonhosted.org/packages/aa/0e/8c79c2f4dd17439f250778f0f34e404994bc9bcd310cf9793b8c4f8b22dd/cryptocompare_fields-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "436aa5ba21849a53cdd34d154f20e0cb40f1adda0e182ddeacb7f57bc5f9ae08",
"md5": "16a6805fc10444c827c4be7a962d5505",
"sha256": "9916559e80b902fe12cdfa993d0f550ecf718471eff3d510bac4eec416434a38"
},
"downloads": -1,
"filename": "cryptocompare_fields-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "16a6805fc10444c827c4be7a962d5505",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 6457,
"upload_time": "2024-04-29T07:35:04",
"upload_time_iso_8601": "2024-04-29T07:35:04.699607Z",
"url": "https://files.pythonhosted.org/packages/43/6a/a5ba21849a53cdd34d154f20e0cb40f1adda0e182ddeacb7f57bc5f9ae08/cryptocompare_fields-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-29 07:35:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "LambertoKalisto",
"github_project": "CryptoCompare",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "cryptocompare-fields"
}