Supported currencies:
AUD | Australian Dollar |
AZN | Azerbaijani Manat |
GBP | British Pound Sterling |
AMD | Armenian Dram |
BYN | Belarusian Ruble |
BGN | Bulgarian Lev |
BRL | Brazilian Real |
HUF | Hungarian Forint |
VND | Vietnamese Dong |
HKD | Hong Kong Dollar |
GEL | Georgian Lari |
DKK | Danish Krone |
AED | United Arab Emirates Dirham |
USD | United States Dollar |
EUR | Euro |
EGP | Egyptian Pound |
INR | Indian Rupee |
IDR | Indonesian Rupiah |
KZT | Kazakhstani Tenge |
CAD | Canadian Dollar |
QAR | Qatari Riyal |
KGS | Kyrgystani Som |
CNY | Chinese Yuan |
MDL | Moldovan Leu |
NZD | New Zealand Dollar |
NOK | Norwegian Krone |
PLN | Polish Zloty |
RON | Romanian Leu |
XDR | Special Drawing Rights |
SGD | Singapore Dollar |
TJS | Tajikistani Somoni |
THB | Thai Baht |
TRY | Turkish Lira |
TMT | Turkmenistani Manat |
UZS | Uzbekistani Som |
UAH | Ukrainian Hryvnia |
CZK | Czech Koruna |
SEK | Swedish Krona |
CHF | Swiss Franc |
RSD | Serbian Dinar |
ZAR | South African Rand |
KRW | South Korean Won |
JPY | Japanese Yen |
1. Quick start
First, install exchango. Enter this command in the console or in the terminal:
pip install exchango
Next, select the synchronous or asynchronous version of the library.
import exchango.sync_api as exchango
import exchango.async_api as exchango
The difference in usage is almost imperceptible, but the asynchronous version must be applied in async def
and await
before calling the function or in asyncio.run()
.
The difference between synchronous and asynchronous versions.
import exchango.sync_api as exchango
from time import time
codes = ["AUD", "AZN", "GBP", "AMD", "BYN", "BGN", "BRL", "HUF", "VND", "HKD", "GEL", "DKK", "AED", "USD", "EUR", "EGP", "INR", "IDR", "KZT", "CAD", "QAR", "KGS", "CNY", "MDL", "NZD", "NOK", "PLN", "RON", "XDR", "SGD", "TJS", "THB", "TRY", "TMT", "UZS", "UAH", "CZK", "SEK", "CHF", "RSD", "ZAR", "KRW", "JPY"]
def main():
start = time()
for currency in codes:
for to in codes:
for amount in range(0, 11):
result = exchango.convert(currency, amount, to)
print(f"{amount} {currency} = {result} {to}")
end = time()
print(end - start)
if __name__ == "__main__":
main()
import exchango.async_api as exchango
from time import time
import asyncio
codes = ["AUD", "AZN", "GBP", "AMD", "BYN", "BGN", "BRL", "HUF", "VND", "HKD", "GEL", "DKK", "AED", "USD", "EUR", "EGP", "INR", "IDR", "KZT", "CAD", "QAR", "KGS", "CNY", "MDL", "NZD", "NOK", "PLN", "RON", "XDR", "SGD", "TJS", "THB", "TRY", "TMT", "UZS", "UAH", "CZK", "SEK", "CHF", "RSD", "ZAR", "KRW", "JPY"]
async def main():
start = time()
for currency in codes:
for to in codes:
for amount in range(0, 11):
result = await exchango.convert(currency, amount, to)
print(f"{amount} {currency} = {result} {to}")
end = time()
print(end - start)
if __name__ == "__main__":
asyncio.run(main())
This code calls the exchango.convert
function 20339 times and at the end outputs how much time was spent.
Currency converting.
exchango.convert(currency, amount, to)
await exchango.convert(currency, amount, to)
currency | 3-letter code of the currency to convert | string | USD | EUR | RUB |
amount | Amount of currency to convert into another currency | number | 5 | 91.84 | -647 |
to | 3-letter code of the target currency to convert currency into | string | RUB | USD | EUR |
number | YES | Converting result | 500.0 | 145.1541451 | -23.535 |
string | NO | Error during converting | Incorrect type | Unspecified argument | And other |