<div align="center">
<img src="https://static.pepy.tech/badge/YnExchangePY"><img/>
<img src="https://static.pepy.tech/badge/YnExchangePY/month"><img/>
<img src="https://static.pepy.tech/badge/YnExchangePY/week"><img/>
</div><br/><br/>
# Documentation
### Description:
This Python library provides functionalities to get cryptocurrency prices and perform conversions between Iranian Toman (IRT) and USD, for all supported cryptocurrencies.
### Key Features:
* Get the current price of various cryptocurrencies in IRT or USD.
* Convert between IRT and USD for any of the supported cryptocurrencies.
* Get country currencies price
* Get chart of crypto prices
* Smart crypto calculator
* Donate to the library developer (optional).
# Installation
```bash
pip install YnExchangePY
```
# Functionality
The library provides functions for retrieving the price of all cryptocurrencies. Each function takes 3 arguments:<br/>
* currency (str): This argument specifies the desired currency (either "IRT" or "USD").
* grouping (bool, optional): This argument is optional (defaults to False). If set to True, the function will format the price with comma separators for readability.
* crypto_name (str) : This argument is for the name of the desired crypto to get its price<br/><br/>
**Here's a list of all the available functions:**
* ```YN_Exchange.CRYPTO_PRICES(crypto_name : str,currency:str,grouping : bool = False)```
* ```YN_Exchange.GOLD_PRICE(carat : int,mass : str="gram")```
* ```YN_Exchange.CURRENCY_PRICE(currency : str,price_currency : str = "IRT")```
* ```YN_Exchange.USD_PRICE()```
* ```YN_Exchange.CRYPTO_CHART(crypto : str,timeout : int=5,currency : str="usd")```
* ```YN_Exchange.CALCULATOR(value:float,currency:str,crypto:str,grouping : bool=False,calculat_mode : str="CV2C",other_crypto : str = None)```
* ```YN_Exchange.DONATE()```
# Example Usage
### Get crypto live prices:
```python
import YN_Exchange
# Get Bitcoin price in USD with grouping
bitcoin_usd_price = YN_Exchange.CRYPTO_PRICES(crypto_name="BTC",currency="USD",grouping=True)
print(f"Bitcoin price in USD: ${bitcoin_usd_price}")
# Get Ethereum price in IRT(no grouping)
ethereum_irt_price = YN_Exchange.CRYPTO_PRICES(crypto_name="ETH",currency="IRT")
print(f"Ethereum price in IRT: {ethereum_irt_price}")
```
### Get gold price (Only IRT currency):
```python
import YN_Exchange
# Get 18k ct gold with gram:
_18k_gold=YN_Exchange.GOLD_PRICE(carat=18,mass="gram") # You can give "kilo" parameter to mass to calculate kilograms
print(_18k_gold)
# Get 24k ct gold with gram:
_24k_gold=YN_Exchange.GOLD_PRICE(carat=24,mass="gram") # You can give "kilo" parameter to mass to calculate kilograms
print(_24k_gold)
```
### Get price of ounce metals (Only USD currency):
This method is being updated
### Get currency prices:
```python
import YN_Exchange
# Get USD(united state dollar) price (Only IRT):
usd_price=YN_Exchange.USD_PRICE()
print(usd_prices)
# Get EUR(europe euro) price:
eur_price=YN_Exchange.CURRENCY_PRICE(currency="EUR",price_currency="USD") # You can use "IRT" parameter instead of "USD" parameter
print(eur_price)
```
The USD function is separated from the main function due to differences
### Get chart of crypto prices:
```python
import YN_Exchange
#Get bitcoin price chart
YN_Exchange.CRYPTO_CHART(crypto="BTC",timeout=7,currency="USD")
```
* After executing this method, a file named "{your crypto} chart.png" will be created.
* Some cryptocurrencies do not have a table with USD currency, so you have to use IRT currency.
* If there is a problem in displaying the table, it will be displayed in the photo.
* The "timeout" argument is the amount of time the page takes to load.
* If you have a weak internet, set the "timeout" argument to a number above 7
* After completing the operation, the message "SAVED!" It will be printed
### Crypto calculator
```python
import YN_Exchange
# Converting an amount of a crypto to the total price
print(CALCULATOR(value=10,currency="USD",crypto="USDT",grouping=False,calculat_mode="CV2C"))
# Converting an amount from one crypto to another
print(CALCULATOR(value=10,currency="USD",crypto="USDT",grouping=False,calculat_mode="CV2OC",other_crypto="TON"))
```
* calculat_mode : An argument related to the type of calculation ( CV2C : Crypto Value To Currency | CV2OC : Crypto Value To Other Crypto )
* other_crypto : An argument that is only for "CV2OC" mode to perform the calculation
# Error Handling
If the function encounters an error, such as an invalid currency or a network issue, it will raise a ```ValueError``` exception. You can handle this exception using a try-except block.
# Limitations
* The library relies on scraping data from a website, which may be subject to changes or become unavailable.
* The library only supports a limited number of cryptocurrencies.
# Additional notes
### Here are some ways you can contribute to the YN_Exchange project:
* **Donate:** If you've found my library to be useful, I would greatly appreciate it if you would consider making a donation. Your donation will help me to continue to develop and maintain the library, and to add new features in the future.
**Donate function**
```python
YN_Exchange.DONATE()
```
Raw data
{
"_id": null,
"home_page": null,
"name": "YnExchangePY",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, crypto, prices, crypto calculations, api, calculations",
"author": "Yasha Najafi(YN)",
"author_email": "<najafiyasha@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/5b/61/2ffc8370719ffe1d86de5af21fbbff265476759c6d971541be9599a6d540/YnExchangePY-5.0.1.tar.gz",
"platform": null,
"description": "\r\n<div align=\"center\">\r\n\r\n <img src=\"https://static.pepy.tech/badge/YnExchangePY\"><img/>\r\n\r\n <img src=\"https://static.pepy.tech/badge/YnExchangePY/month\"><img/>\r\n\r\n <img src=\"https://static.pepy.tech/badge/YnExchangePY/week\"><img/>\r\n\r\n</div><br/><br/>\r\n\r\n\r\n\r\n# Documentation\r\n\r\n\r\n\r\n### Description:\r\n\r\nThis Python library provides functionalities to get cryptocurrency prices and perform conversions between Iranian Toman (IRT) and USD, for all supported cryptocurrencies.\r\n\r\n\r\n\r\n### Key Features:\r\n\r\n* Get the current price of various cryptocurrencies in IRT or USD.\r\n\r\n* Convert between IRT and USD for any of the supported cryptocurrencies.\r\n\r\n* Get country currencies price\r\n\r\n* Get chart of crypto prices\r\n\r\n* Smart crypto calculator\r\n\r\n* Donate to the library developer (optional).\r\n\r\n\r\n\r\n# Installation\r\n\r\n```bash\r\n\r\npip install YnExchangePY\r\n\r\n```\r\n\r\n# Functionality\r\n\r\nThe library provides functions for retrieving the price of all cryptocurrencies. Each function takes 3 arguments:<br/>\r\n\r\n* currency (str): This argument specifies the desired currency (either \"IRT\" or \"USD\").\r\n\r\n* grouping (bool, optional): This argument is optional (defaults to False). If set to True, the function will format the price with comma separators for readability.\r\n\r\n* crypto_name (str) : This argument is for the name of the desired crypto to get its price<br/><br/>\r\n\r\n**Here's a list of all the available functions:**\r\n\r\n* ```YN_Exchange.CRYPTO_PRICES(crypto_name : str,currency:str,grouping : bool = False)```\r\n\r\n* ```YN_Exchange.GOLD_PRICE(carat : int,mass : str=\"gram\")```\r\n\r\n* ```YN_Exchange.CURRENCY_PRICE(currency : str,price_currency : str = \"IRT\")```\r\n\r\n* ```YN_Exchange.USD_PRICE()```\r\n\r\n* ```YN_Exchange.CRYPTO_CHART(crypto : str,timeout : int=5,currency : str=\"usd\")```\r\n\r\n* ```YN_Exchange.CALCULATOR(value:float,currency:str,crypto:str,grouping : bool=False,calculat_mode : str=\"CV2C\",other_crypto : str = None)```\r\n\r\n* ```YN_Exchange.DONATE()```\r\n\r\n\r\n\r\n# Example Usage\r\n\r\n### Get crypto live prices:\r\n\r\n```python\r\n\r\nimport YN_Exchange\r\n\r\n\r\n\r\n# Get Bitcoin price in USD with grouping\r\n\r\nbitcoin_usd_price = YN_Exchange.CRYPTO_PRICES(crypto_name=\"BTC\",currency=\"USD\",grouping=True)\r\n\r\nprint(f\"Bitcoin price in USD: ${bitcoin_usd_price}\")\r\n\r\n\r\n\r\n# Get Ethereum price in IRT(no grouping)\r\n\r\nethereum_irt_price = YN_Exchange.CRYPTO_PRICES(crypto_name=\"ETH\",currency=\"IRT\")\r\n\r\nprint(f\"Ethereum price in IRT: {ethereum_irt_price}\")\r\n\r\n```\r\n\r\n### Get gold price (Only IRT currency):\r\n\r\n```python\r\n\r\nimport YN_Exchange\r\n\r\n\r\n\r\n# Get 18k ct gold with gram:\r\n\r\n_18k_gold=YN_Exchange.GOLD_PRICE(carat=18,mass=\"gram\") # You can give \"kilo\" parameter to mass to calculate kilograms\r\n\r\nprint(_18k_gold)\r\n\r\n\r\n\r\n# Get 24k ct gold with gram:\r\n\r\n_24k_gold=YN_Exchange.GOLD_PRICE(carat=24,mass=\"gram\") # You can give \"kilo\" parameter to mass to calculate kilograms\r\n\r\nprint(_24k_gold)\r\n\r\n```\r\n\r\n### Get price of ounce metals (Only USD currency):\r\n\r\nThis method is being updated\r\n\r\n### Get currency prices:\r\n\r\n```python\r\n\r\nimport YN_Exchange\r\n\r\n\r\n\r\n# Get USD(united state dollar) price (Only IRT):\r\n\r\nusd_price=YN_Exchange.USD_PRICE()\r\n\r\nprint(usd_prices)\r\n\r\n\r\n\r\n# Get EUR(europe euro) price:\r\n\r\neur_price=YN_Exchange.CURRENCY_PRICE(currency=\"EUR\",price_currency=\"USD\") # You can use \"IRT\" parameter instead of \"USD\" parameter\r\n\r\nprint(eur_price)\r\n\r\n```\r\n\r\nThe USD function is separated from the main function due to differences\r\n\r\n### Get chart of crypto prices:\r\n\r\n```python\r\n\r\nimport YN_Exchange\r\n\r\n\r\n\r\n#Get bitcoin price chart\r\n\r\nYN_Exchange.CRYPTO_CHART(crypto=\"BTC\",timeout=7,currency=\"USD\")\r\n\r\n```\r\n\r\n* After executing this method, a file named \"{your crypto} chart.png\" will be created.\r\n\r\n* Some cryptocurrencies do not have a table with USD currency, so you have to use IRT currency.\r\n\r\n* If there is a problem in displaying the table, it will be displayed in the photo.\r\n\r\n* The \"timeout\" argument is the amount of time the page takes to load.\r\n\r\n* If you have a weak internet, set the \"timeout\" argument to a number above 7\r\n\r\n* After completing the operation, the message \"SAVED!\" It will be printed\r\n\r\n### Crypto calculator\r\n\r\n```python\r\n\r\nimport YN_Exchange\r\n\r\n\r\n\r\n# Converting an amount of a crypto to the total price\r\n\r\nprint(CALCULATOR(value=10,currency=\"USD\",crypto=\"USDT\",grouping=False,calculat_mode=\"CV2C\"))\r\n\r\n\r\n\r\n# Converting an amount from one crypto to another\r\n\r\nprint(CALCULATOR(value=10,currency=\"USD\",crypto=\"USDT\",grouping=False,calculat_mode=\"CV2OC\",other_crypto=\"TON\"))\r\n\r\n```\r\n\r\n* calculat_mode : An argument related to the type of calculation ( CV2C : Crypto Value To Currency | CV2OC : Crypto Value To Other Crypto )\r\n\r\n* other_crypto : An argument that is only for \"CV2OC\" mode to perform the calculation\r\n\r\n# Error Handling\r\n\r\nIf the function encounters an error, such as an invalid currency or a network issue, it will raise a ```ValueError``` exception. You can handle this exception using a try-except block.\r\n\r\n# Limitations\r\n\r\n* The library relies on scraping data from a website, which may be subject to changes or become unavailable.\r\n\r\n* The library only supports a limited number of cryptocurrencies.\r\n\r\n# Additional notes\r\n\r\n### Here are some ways you can contribute to the YN_Exchange project:\r\n\r\n* **Donate:** If you've found my library to be useful, I would greatly appreciate it if you would consider making a donation. Your donation will help me to continue to develop and maintain the library, and to add new features in the future.\r\n\r\n\r\n\r\n**Donate function**\r\n\r\n```python\r\n\r\nYN_Exchange.DONATE()\r\n\r\n```\r\n\r\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "5.0.1",
"project_urls": null,
"split_keywords": [
"python",
" crypto",
" prices",
" crypto calculations",
" api",
" calculations"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b16dbfe01734a582bd2af10e4e5283af792916ed34303b99fd8705c5f0007885",
"md5": "d23354f6a08be9d01a5cd8c92344e35b",
"sha256": "24b36daae8f7bb42f8a08c2319713ff138790403b4db3751d36f24cd78fe04ab"
},
"downloads": -1,
"filename": "YnExchangePY-5.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d23354f6a08be9d01a5cd8c92344e35b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5454,
"upload_time": "2024-09-12T12:04:33",
"upload_time_iso_8601": "2024-09-12T12:04:33.750088Z",
"url": "https://files.pythonhosted.org/packages/b1/6d/bfe01734a582bd2af10e4e5283af792916ed34303b99fd8705c5f0007885/YnExchangePY-5.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5b612ffc8370719ffe1d86de5af21fbbff265476759c6d971541be9599a6d540",
"md5": "83dc2e8682d893ffb742983462598d59",
"sha256": "5590e87343c95a34978c8ec27b54aeb09b579fc2a23b515cb14fb8f09209b5cd"
},
"downloads": -1,
"filename": "YnExchangePY-5.0.1.tar.gz",
"has_sig": false,
"md5_digest": "83dc2e8682d893ffb742983462598d59",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5439,
"upload_time": "2024-09-12T12:04:35",
"upload_time_iso_8601": "2024-09-12T12:04:35.033320Z",
"url": "https://files.pythonhosted.org/packages/5b/61/2ffc8370719ffe1d86de5af21fbbff265476759c6d971541be9599a6d540/YnExchangePY-5.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-12 12:04:35",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ynexchangepy"
}