Metadata-Version: 2.4
Name: gheymat
Version: 0.4.0
Summary: A Python package for getting live prices of currencies, cryptocurrencies, gold, coins, and precious metals.
Author-email: Ali Heydari <imrrobat@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/imrrobat/gheymat
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: beautifulsoup4
Dynamic: license-file

# Gheymat

A simple Python package for getting live prices of currencies, cryptocurrencies, gold, coins, and precious metals.

If this package is useful for you, you can support me with a coffee ☕😁

https://www.coffeebede.com/mrrobat

![Downloads](https://static.pepy.tech/personalized-badge/gheymat?period=total&units=international_system&left_color=black&right_color=green&left_text=Downloads)

---

## Installation

```bash
pip install gheymat
```

---

## Supported Prices

### Currencies

| Currency | Value |
| --- | --- |
| US Dollar | `usd` |
| British Pound | `gbp` |
| Euro | `eur` |
| Turkish Lira | `try` |
| UAE Dirham | `aed` |
| Chinese Yuan | `cny` |
| Indian Rupee | `inr` |
| Swedish Krona | `sek` |
| Omani Rial | `omr` |

### Cryptocurrencies

| Cryptocurrency | Value |
| --- | --- |
| Bitcoin | `btc` |
| Ethereum | `eth` |
| Dogecoin | `doge` |
| Solana | `sol` |
| Tron | `tron` |
| Ripple | `ripp` |
| Dash | `dash` |
| Litecoin | `lite` |
| Stellar | `stell` |
| Toncoin | `ton` |

### Gold, Coins, and Metals

| Item | Value |
| --- | --- |
| 18K Gold | `gold18` |
| 24K Gold | `gold24` |
| Used Gold | `used_gold` |
| Emami Coin | `seke_emam` |
| Bahar Azadi Coin | `seke_bahar` |
| 999 Silver | `silver` |

---

# Usage in Python

## Currency Prices

Import `get_price` from `gheymat.currency`.

```python
from gheymat.currency import get_price
```

### Get US Dollar Price in Toman

```python
dollar_price = get_price("usd", toman=True)
print(dollar_price)
```

### Get Euro Price in Rial

```python
euro_price = get_price("eur", toman=False)
print(euro_price)
```

### Get Pound Price With Commas

```python
pound_price = get_price("gbp", toman=True, beauty=True)
print(pound_price)

# Example output:
# 1,520,000
```

### Currency Function Parameters

```python
get_price(currency="usd", toman=True, beauty=False)
```

| Parameter | Default | Description |
| --- | --- | --- |
| `currency` | `"usd"` | Currency value. Example: `"usd"`, `"eur"`, `"gbp"`, or `"aed"`. |
| `toman` | `True` | If `True`, returns the price in Toman. If `False`, returns the price in Rial. |
| `beauty` | `False` | If `True`, returns the price as a formatted string with commas. |

Currency values are not case-sensitive:

```python
get_price("usd")
get_price("USD")
get_price("Usd")
```

All of them work the same.

---

## Cryptocurrency Prices

Import `get_price` from `gheymat.crypto`.

```python
from gheymat.crypto import get_price
```

### Get Bitcoin Price in USD

```python
bitcoin_price = get_price("btc", toman=False)
print(bitcoin_price)
```

### Get Bitcoin Price in Toman

```python
bitcoin_price = get_price("btc", toman=True)
print(bitcoin_price)
```

### Get Ethereum Price in Toman With Commas

```python
ethereum_price = get_price("eth", toman=True, beauty=True)
print(ethereum_price)

# Example output:
# 302,500,000
```

### Cryptocurrency Function Parameters

```python
get_price(crypto="btc", toman=True, beauty=False)
```

| Parameter | Default | Description |
| --- | --- | --- |
| `crypto` | `"btc"` | Crypto value. Example: `"btc"`, `"eth"`, `"doge"`, or `"ton"`. |
| `toman` | `True` | If `True`, returns the price in Toman. If `False`, returns the price in USD. |
| `beauty` | `False` | If `True`, returns the price as a formatted string with commas. |

> **Note:** `TON` price is received from CoinMarketCap. Other supported cryptocurrencies are received from TGJU.

---

## TON Configuration

To get the price of Toncoin (`ton`), you need a CoinMarketCap API key.

Create an API key from CoinMarketCap and set it as an environment variable named:

```text
COINMARKETCAP_API_KEY
```

### Windows PowerShell

```powershell
$env:COINMARKETCAP_API_KEY="your_api_key"
```

### Git Bash

```bash
export COINMARKETCAP_API_KEY="your_api_key"
```

Then use TON normally:

```python
from gheymat.crypto import get_price

ton_price = get_price("ton", toman=True, beauty=True)
print(ton_price)
```

> Do not put your API key directly in your source code or upload it to GitHub.

---

## Gold, Coin, and Metal Prices

Import `get_price` from `gheymat.metal`.

```python
from gheymat.metal import get_price
```

### Get 18K Gold Price in Toman

```python
gold_price = get_price("gold18", toman=True)
print(gold_price)
```

### Get Emami Coin Price With Commas

```python
emami_coin_price = get_price("seke_emam", toman=True, beauty=True)
print(emami_coin_price)
```

### Get Silver Price in Rial

```python
silver_price = get_price("silver", toman=False)
print(silver_price)
```

### Metal Function Parameters

```python
get_price(metal="gold18", toman=True, beauty=False)
```

| Parameter | Default | Description |
| --- | --- | --- |
| `metal` | `"gold18"` | Metal or coin value. Example: `"gold18"`, `"silver"`, or `"seke_emam"`. |
| `toman` | `True` | If `True`, returns the price in Toman. If `False`, returns the price in Rial. |
| `beauty` | `False` | If `True`, returns the price as a formatted string with commas. |

---

# Usage in Terminal

You can also use Gheymat directly in your terminal.

## Currency

```bash
python -m gheymat.currency usd --toman
```

Get the price in Rial:

```bash
python -m gheymat.currency eur --rial
```

Get a formatted price:

```bash
python -m gheymat.currency gbp --toman --beauty
```

---

## Cryptocurrency

Get Bitcoin price in USD:

```bash
python -m gheymat.crypto btc --usd
```

Get Bitcoin price in Toman:

```bash
python -m gheymat.crypto btc --toman
```

Get formatted Ethereum price in Toman:

```bash
python -m gheymat.crypto eth --toman --beauty
```

Get TON price in Toman:

```bash
python -m gheymat.crypto ton --toman --beauty
```

---

## Gold, Coin, and Metal

Get 18K gold price in Toman:

```bash
python -m gheymat.metal gold18 --toman
```

Get Emami coin price with commas:

```bash
python -m gheymat.metal seke_emam --toman --beauty
```

Get silver price in Rial:

```bash
python -m gheymat.metal silver --rial --beauty
```

---

## Terminal Help

Use `--help` to see all available options.

```bash
python -m gheymat.currency --help
```

```bash
python -m gheymat.crypto --help
```

```bash
python -m gheymat.metal --help
```

---

## Notes

- Prices are collected from online sources and may change at any time.
- Currency, gold, coin, metal, and most crypto prices are collected from TGJU.
- TON price is collected from CoinMarketCap.
- This package depends on the structure and availability of source websites.
- If a source website changes its HTML structure or API, the package may need an update.
- Use returned prices for informational purposes only.
- When `beauty=True`, the returned value is a `str`.
- When `beauty=False`, the returned value is usually an `int` or `float`.

---

## Support

If you like this package and want to support its development, you can buy me a coffee ☕😁

https://www.coffeebede.com/mrrobat

---

## License
This project is available under the MIT License.
