Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created Exchange Rate API #1108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions jarviscli/plugins/exchange_rate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from plugin import plugin
import requests

@plugin('exchange_rate')


def exchange_rate(jarvis, s):
print('Showing exchange rate on global currencies\n\n')

CURRENCIES = [
'USD/US Dollar',
'EUR/Euro',
'JPY/Japanese yen',
'GBP/Pound sterling',
'AUD/ Australian dollar',
'CAD/Canadian dollar',
'CHF/Swiss franc',
'CNH/Chinese renminbi',
'HKD/Hong Kong dollar'
]

print("Examples")
for curr in CURRENCIES:
print(curr)

curr1 = str(input("\nPlease enter your first currency: "))
curr2 = str(input("Please enter your second currency: "))

api_url = 'https://api.api-ninjas.com/v1/exchangerate?pair=' + curr1 +'_' + curr2
response = requests.get(api_url, headers={'X-Api-Key': 'dDcouxccX+Ne1OKZj+rRrw==CW8Mg7Tvlk3u8omW'})
if response.status_code == requests.codes.ok:
print(response.text)
else:
print("Error:", response.status_code, response.text)