https://github.com/juancarlospaco/openexchangerate
OpenExchangeRates API client for Python 3.7+.
https://github.com/juancarlospaco/openexchangerate
bitcoin-price currency cython money namedtuple openexchangerates python3
Last synced: 6 months ago
JSON representation
OpenExchangeRates API client for Python 3.7+.
- Host: GitHub
- URL: https://github.com/juancarlospaco/openexchangerate
- Owner: juancarlospaco
- License: gpl-3.0
- Created: 2017-11-20T12:12:37.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-11T14:41:13.000Z (over 7 years ago)
- Last Synced: 2025-03-09T04:43:46.940Z (7 months ago)
- Topics: bitcoin-price, currency, cython, money, namedtuple, openexchangerates, python3
- Language: Python
- Homepage:
- Size: 367 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: code_of_conduct.md
Awesome Lists containing this project
README
# 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.
- [Example HTML output from `OpenExchangeRates(api_key).latest().html`](https://github.com/juancarlospaco/openexchangerate/blob/master/sample.html)
# Install
```bash
pip install openexchangerate
```# Use
```python
from openexchangerate import OpenExchangeRatesclient = 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)```


# Tests
```
python -m unittest --verbose --locals tests.TestOpenExchangeRates
```- [Test Templates.](https://gist.github.com/juancarlospaco/040fbe326631e638f2a540fe8c1f2092)
# 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](https://openexchangerates.org/account/app-ids), 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 |
| ------------------ |:-----------:| -----------:|
| :white_check_mark: | **Linux** | Works Ok |
| :white_check_mark: | **Os X** | Works Ok |
| :white_check_mark: | **Windows** | Works Ok |**Usage Example:**
```python
>>> 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.](https://github.com/cython/cython/wiki/projects#projects-using-cython) [Please check Cython documentation for more info.](https://cython.readthedocs.io)
### Contributors:
- **Please Star this Repo on Github !**, it helps to show up faster on searchs.
- [Help](https://help.github.com/articles/using-pull-requests) and more [Help](https://help.github.com/articles/fork-a-repo) and Interactive Quick [Git Tutorial](https://try.github.io).
- 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.