GithubHelp home page GithubHelp logo

currency_converter's Introduction

Currency Converter

Currency converter using exchange rates from the http://fixer.io/ API. It uses forex-python to get the currency rates, Flask for providing the web API.

Installation

Python3 +

pip install -r requirements.txt

API Usage

You can start the server by running:

python webservice.py

The API accepts GET parameters:

  • amount
  • input_currency
  • output_currency

To convert $15.24 to EUR, you can call:

http://127.0.0.1:5000/currency_converter?amount=15.24&input_currency=$&output_currency=EUR

which should return JSON:

{
    "input": {
        "amount": 15.24,
        "currency": "USD"
    },
    "output": {
        "EUR": 13.6035288
    }
}

In case of an error, you get 400/500 status codes and the returned JSON will look like:

{
    "error": "'amount' has to be a number."
}

CLI Usage

usage: currency_converter.py [-h] -a AMOUNT -i INPUT_CURRENCY
                             [-o OUTPUT_CURRENCY]

Currency converter using exchange rates from the http://fixer.io/ API.

optional arguments:
  -h, --help            show this help message and exit
  -a AMOUNT, --amount AMOUNT
                        Amount to be converted.
  -i INPUT_CURRENCY, --input_currency INPUT_CURRENCY
                        Input currency. Use either 3 letter code (one of
                        {'USD', 'CHF', 'HRK', 'NZD', 'SGD', 'RON', 'CAD',
                        'KRW', 'BGN', 'MXN', 'RUB', 'DKK', 'HUF', 'THB',
                        'INR', 'EUR', 'AUD', 'SEK', 'BRL', 'IDR', 'CNY',
                        'PHP', 'NOK', 'ILS', 'PLN', 'JPY', 'TRY', 'HKD',
                        'MYR', 'ZAR', 'CZK', 'GBP'}) or currency symbol (one
                        of {'₪', '฿', 'zł', 'R$', 'lei', 'kr', '$', '£', 'RM',
                        '₩', 'Rp', '€', 'kn', '¥', 'руб', 'Php', 'Kč', 'лв',
                        'Ft', 'TL', 'R'})).
  -o OUTPUT_CURRENCY, --output_currency OUTPUT_CURRENCY
                        Currency you want to convert to. If omitted, converts
                        to all currencies {'USD', 'CHF', 'HRK', 'NZD', 'SGD',
                        'RON', 'CAD', 'KRW', 'BGN', 'MXN', 'RUB', 'DKK',
                        'HUF', 'THB', 'INR', 'EUR', 'AUD', 'SEK', 'BRL',
                        'IDR', 'CNY', 'PHP', 'NOK', 'ILS', 'PLN', 'JPY',
                        'TRY', 'HKD', 'MYR', 'ZAR', 'CZK', 'GBP'}.

Tests

To run the test suite, call:

python test.py

currency_converter's People

Contributors

dionysio avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.