Metadata-Version: 2.4
Name: cryptomanager
Version: 0.1.1
Summary: Library for cryptocurrency prices and currency conversion without API keys
Home-page: https://github.com/pavlyska/cryptomanager
Author: pavlyska
Author-email: kozyka2016@gmail.com
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Office/Business :: Financial
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.1
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# CryptoManager

CryptoManager is a small Python library for getting cryptocurrency and fiat exchange rates, converting between currencies, and working with simple money objects.

The library works without required API keys. It tries multiple public providers in order and falls back to the next provider when one of them is unavailable.

## Installation

```bash
pip install cryptomanager
```

## Quick Start

```python
import cryptomanager as cm

btc_usd = cm.price(1, "BTC")
eth_eur = cm.price(1, "ETH", "EUR")

print(f"1 BTC = ${btc_usd:,.2f}")
print(f"1 ETH = EUR {eth_eur:,.2f}")
```

You can also use the global manager object directly:

```python
from cryptomanager import cm

print(cm.price(0.5, "BTC"))
```

## Conversion

```python
import cryptomanager as cm

btc_to_usdt = cm.transfer(1, "BTC").to("USDT")
eth_to_btc = cm.transfer(10, "ETH").to("BTC")
usd_to_eur = cm.transfer(100, "USD").to("EUR")

print(btc_to_usdt)
print(eth_to_btc)
print(usd_to_eur)
```

## Local Fixed-Rate Conversion

Use local conversion when you want to provide your own fixed rate:

```python
import cryptomanager as cm

RUBY_RATE = 90
result = cm.transfer.local(2, "USD").to((RUBY_RATE, "RUBY"))

print(result)  # 180
```

## Money Objects

```python
import cryptomanager as cm

usdt = cm.money("USDT")
amount = usdt(1000)

btc_amount = amount.to("BTC")

print(amount)
print(btc_amount)
```

## Supported Providers

Crypto providers:

- Binance
- CoinGecko
- Coinbase Exchange
- CoinPaprika
- CoinLore
- MEXC
- CoinCap
- CryptoCompare
- Kraken
- Bitfinex
- Huobi
- OKX
- Bybit
- KuCoin
- Gate.io
- Gemini
- Bitstamp
- Bittrex
- CoinMarketCap, optional API key

Fiat providers:

- Frankfurter
- Exchangerate.host
- ExchangeRate-API, optional API key
- Open Exchange Rates, optional API key
- Currency Layer, optional API key
- Fixer.io, optional API key
- Alpha Vantage, optional API key

## API Keys

The package works without API keys, but some optional providers can be enabled:

```python
import cryptomanager as cm

cm.set_api_key("coinmarketcap", "your_api_key")
cm.set_api_key("alphavantage", "your_api_key")
```

Do not commit API keys to GitHub.

## Cache

Rates are cached for 60 seconds by default.

```python
import cryptomanager as cm

cm.set_update_interval(30)
cm.clear_cache()
```

## Supported Currency Lists

```python
import cryptomanager as cm

cryptos = cm.get_supported_cryptos()
fiats = cm.get_supported_fiats()

print(len(cryptos))
print(len(fiats))
```

## Error Handling

Network APIs can fail, rate-limit requests, or temporarily return incomplete data. Wrap live price calls in `try`/`except`:

```python
import cryptomanager as cm

try:
    price = cm.price(1, "BTC")
    print(price)
except ValueError as exc:
    print(f"Could not get price: {exc}")
```

## Development

Install the local project in editable mode:

```bash
python -m pip install -e .
```

Run smoke tests:

```bash
python tests.py
python test_examples.py
```

Build release files:

```bash
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
```

Upload to PyPI:

```bash
python -m twine upload dist/*
```

Use `__token__` as the username and your PyPI API token as the password.

## License

MIT License. See [LICENSE](LICENSE).
