Skip to main content

This library uses the api functionality of ExchangeRateApi, it will make use of the request library in order to make the requests from the ExchangeRateApi.

Project description

Exchange Rate Api

ExchangeRateApi is an unofficial python library which allows to use the api functionality of ExchangeRateApi, it will make use of the request library in order to make the requests from the ExchangeRateApi.

Installation

Use the package manager pip to install Exchange Rate Api

pip install exchangerateapi

Usage

The ExchangeRateApi takes 1 argument

# Initialize an object to ExchangeRateApi
from ExchangeRateApi import *

api = ExchangeRateApi("YOUR_API_KEY")

There are 7 methods

  1. get_latest
  2. get_pair_conversion
  3. get_codes
  4. get_quota
  5. get_enriched_data
  6. get_historical_data
  7. search
from ExchangeRateApi import *
import pprint

api = ExchangeRateApi("YOUR_API_KEY")

pprint.pprint(api.get_latest("INR"))  # get_latest method returns a dictionary

print(api.get_pair_conversion("INR", "USD", 2.0)) # get_pair_conversion returns a string

pprint.pprint(api.get_codes()) # get_codes returns a dictionary

print(api.get_quota()) # get_quota returns a string

print(api.get_enriched_data("INR","USD")) # get_enriched_data returns a string

pprint.pprint(api.get_historical_data("INR",20,12,2000,2.0)) # get_historical_data returns a dictionary

api.search("in") # returns a dictionary if is_print is False

Features

  • Exception

    New exceptions has been included

    • InvalidKeyError
    • InactiveAccountError
    • QuotaExceededError
    • UnsupportedCodeError
    • MalformedRequestError
    • PlanUpgradeRequiredError
    • NoDataAvailableError
    • CliFormatError
    • NoArgumentError
  • Command Line Interface

    Command line interface has been added to this package

  usage: ExchangeRateApi [-h] -k KEY [-q QUOTA] [-l LATEST] [-c CURRENCY] [-p [PAIR [PAIR ...]]] [-e ENRICHED ENRICHED] [-H [HISTORICAL [HISTORICAL ...]]]
                      [-s [SEARCH [SEARCH ...]]]

  This library will allow the user to use the api functionality of ExchangeRateApi, it will make use of the request library in order to make the requests from
  the ExchangeRateApi.

  optional arguments:
  -h, --help            show this help message and exit
  -k KEY, --key KEY     Api key for the ExchangeRateApi
  -q QUOTA, --quota QUOTA
                          Gives the quota for the api key
  -l LATEST, --latest LATEST
                          Gives the latest exchange rate of the currency
  -c CURRENCY, --currency CURRENCY
                          Gives the supported codes
  -p [PAIR [PAIR ...]], --pair [PAIR [PAIR ...]]
                          Converts the first currency to the second currency and if any amount is given it will be converted to the specified amount Format -
                          Currency Currency Amount = 1
  -e ENRICHED ENRICHED, --enriched ENRICHED ENRICHED
                          Converts the first currency to the second currency and if any amount is given it will be converted to the specified amount and gives
                          the enriched data The information contains : - Country - Two-Letter Code - Currency Name - Currency Name short - Symbol - Flag Url
                          Format - Currency Currency
  -H [HISTORICAL [HISTORICAL ...]], --historical [HISTORICAL [HISTORICAL ...]]
                          Gives the historical data of the currency and users should provide date, month and year Format - Currency Date Month Year Amount = 1
  -s [SEARCH [SEARCH ...]], --search [SEARCH [SEARCH ...]]
                          Searches for the currency codes in order to give the valid currency code Format - Key is_country=0 Provide is_country as 1 if you
                          want to get the currency code for the country else leave it empty
cli cli-optional

Test cases has been included

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ExchangeRateApi-0.1.0.tar.gz (12.2 kB view hashes)

Uploaded Source

Built Distribution

ExchangeRateApi-0.1.0-py3-none-any.whl (25.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page