Code Monkey home page Code Monkey logo

openexchangerate's Introduction

openexchangerate

OpenExchangeRates API client for Python 3.7+, worldwide exchange prices + Bitcoin price + Gold price. Can be used as context manager or iterator. Namedtuple, dict and HTML outputs. No dependencies. Float or Decimal. Optional Timeout. Optional round. 1 file.

screenshot

Install

pip install openexchangerate

Use

from openexchangerate import OpenExchangeRates

client = OpenExchangeRates(api_key="21e7c27676972")

client.latest().namedtuple      # .dict for Dictionary, .html for HTML.
client.currencies().namedtuple  # .frozendict for Inmutable Dictionary.

for name, price in client:  # Iterator support.
    print(name, price)

with client as prices:  # Context Manager support.
    print(prices.frozendict)

screenshot

screenshot

Tests

python -m unittest --verbose --locals tests.TestOpenExchangeRates

Description of OpenExchangeRates

OpenExchangeRates

openexchangerate.OpenExchangeRates(api_key: str, timeout: int=60, use_float: bool=True, round_float: bool=True, base: str='USD', local_base: str=None)

Description: Returns namedtuple or dict with current international exchange prices and Bitcoin price.

Arguments:

  • api_key Your API Key, you can get one API Key for Free, string type.
  • timeout Timeout on Seconds for network connections, integer type, optional.
  • use_float True for float, False for decimal.Decimal, boolean type, optional.
  • round_float True to round floats to 2 decimals, using round(float, 2), boolean type, optional.
  • base Base currency, Only for Pay accounts!, defaults to "USD", string type, optional.
  • local_base Local Base currency, for Free accounts, to calculate values locally (offline), string type, optional.

Keyword Arguments: None.

Returns: collections.namedtuple.

Dependencies: None.

Source Code file: https://github.com/juancarlospaco/openexchangerate/blob/master/openexchangerate.py

State OS Description
Linux Works Ok
Os X Works Ok
Windows Works Ok

Usage Example:

>>> from openexchangerate import OpenExchangeRates
>>> OpenExchangeRates("21e7c27676972").latest()

Speed

Maximum performance for advanced Linux users.
sudo pip install cython

Cython basically translates Python 3 to C and then Compiles C to Binary, then you can import the generated *.so module as a normal Python module.

Its 100% Optional, but recommend. We check that Cython Compiles on Travis.

You dont have to learn anything about Cython, it just works automatically. The Packages on PyPi dont have any *.c, *.cpp, *.pyc, *.so.

Cython is used by lots of projects and companies. Please check Cython documentation for more info.

Contributors:

  • Please Star this Repo on Github !, it helps to show up faster on searchs.
  • Help and more Help and Interactive Quick Git Tutorial.
  • English is the primary default spoken language, unless explicitly stated otherwise (eg. Dont send Translation Pull Request)
  • Pull Requests for working passing unittests welcomed.

Licence:

  • GNU GPL Latest Version and GNU LGPL Latest Version and any Licence YOU Request via Bug Report.

Ethics and Humanism Policy:

  • Religions is not allowed. Contributing means you agree with the COC.

openexchangerate's People

Contributors

juancarlospaco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.