Skip to main content

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

Release files for ExchangeRateApi 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ExchangeRateApi 0.1.0
File Size Uploaded
ExchangeRateApi-0.1.0.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ExchangeRateApi 0.1.0
File Interpreter ABI Platform
ExchangeRateApi-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.6 kB

Release files / ExchangeRateApi-0.1.0.tar.gz

Download URL ExchangeRateApi-0.1.0.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
94ce3438939ce59c4e52ea66188b1f24e0baaf5f6fa6687490e0b3471cd78568
BLAKE2b-256 checksum
How to use checksums
c0c3c9883308525a1ea03a5db4db8f4df16e28235c48ee7093579a48e8611230
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release files / ExchangeRateApi-0.1.0-py3-none-any.whl

Download URL ExchangeRateApi-0.1.0-py3-none-any.whl
Size 25.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
965daf39d87945c97b5d0a7838ffd8c58e7b118c8e734e9049210b356c96e9fb
BLAKE2b-256 checksum
How to use checksums
77a7dda61ed9b6b2f322a9a8cfdf3ca791314d502cff7bd890943f697511b206
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page