Skip to main content

XECD REST Client

Project description

XE Currency Data Client - Python

XE.com Inc. is the World's Trusted Currency Authority. This project provides an SDK to interface with our XE Currency Data (XECD) product.

XE Currency Data is a REST API that gives you access to daily or live rates and historic mid-market conversion rates between all of our supported currencies.

You will need an api key and secret to use this sdk. Sign up for a free trial or register for a full account.

This client will work with both python2 and python3.

Installation

The preferred way to install this package is pip.

pip install xecd-rates-client

Or get the latest version from git:

pip install git+https://github.com/XenonLab/xecd-rates-client-python.git

This package follows semantic versioning.

Usage

>>> from xecd_rates_client import XecdClient
>>> xecd = XecdClient('ACCOUNT_ID', 'API_KEY')

>>> xecd.account_info()
{'id': '11111111-1111-1111-1111-111111111111', 'organization': 'YOUR_ORG', 'package': 'ENTERPRISE_LIVE_INTERNAL', 'service_start_timestamp': '2018-01-01T00:00:00Z'}

>>> xecd.convert_from("EUR", "CAD", 55)
{'terms': 'http://www.xe.com/legal/dfs.php', 'privacy': 'http://www.xe.com/privacy.php', 'from': 'EUR', 'amount': 55.0, 'timestamp': '2018-08-21T15:31:00Z', 'to': [{'quotecurrency': 'CAD', 'mid': 82.7121317322}]}

>>> xecd.convert_to("RUB", "CAD", 55)
{'terms': 'http://www.xe.com/legal/dfs.php', 'privacy': 'http://www.xe.com/privacy.php', 'to': 'RUB', 'amount': 55.0, 'timestamp': '2018-08-21T15:32:00Z', 'from': [{'quotecurrency': 'CAD', 'mid': 1.0652293852}]}

>>> xecd.historic_rate("2016-12-25", "12:34", "EUR", "CAD", 55)
{'terms': 'http://www.xe.com/legal/dfs.php', 'privacy': 'http://www.xe.com/privacy.php', 'from': 'EUR', 'amount': 55.0, 'timestamp': '2016-12-25T13:00:00Z', 'to': [{'quotecurrency': 'CAD', 'mid': 77.8883951909}]}

>>> xecd.historic_rate_period(55, "EUR", "RUB", "2016-02-28T12:00", "2016-03-03T12:00")
{'terms': 'http://www.xe.com/legal/dfs.php', 'privacy': 'http://www.xe.com/privacy.php', 'from': 'EUR', 'amount': 55.0, 'to': {'RUB': [{'mid': 4590.1222691671, 'timestamp': '2016-02-28T12:00:00Z'}, {'mid': 4545.42879069, 'timestamp': '2016-02-29T12:00:00Z'}, {'mid': 4433.0643335184, 'timestamp': '2016-03-01T12:00:00Z'}, {'mid': 4409.6291908683, 'timestamp': '2016-03-02T12:00:00Z'}, {'mid': 4396.2068371801, 'timestamp': '2016-03-03T12:00:00Z'}]}}

>>> xecd.monthly_average(55, "CAD", "EUR", 2017, 5)
{'terms': 'http://www.xe.com/legal/dfs.php', 'privacy': 'http://www.xe.com/privacy.php', 'from': 'CAD', 'amount': 55.0, 'year': 2017, 'to': {'EUR': [{'monthlyAverage': 36.5976590134, 'month': 5, 'daysInMonth': 31}]}}

Documentation

Technical Specifications

Contributing

xecd_rates_client_python is an open-source project. Submit a pull request to contribute!

Testing

python3 -m test.UnitTest
python3 -m test.IntegrationTest
python -m test.IntegrationTest

Note: the UnitTest must be ran with python3 due to its use of unittest.mock (which is not present as of python2.7). Despite this, the client itself is usable with both python 2 and 3.

Security Issues

If you discover a security vulnerability within this package, please DO NOT publish it publicly. Instead, contact us at security [at] xe.com. We will follow up with you as soon as possible.

About Us

XE.com Inc. is The World's Trusted Currency Authority. Development of this project is led by the XE.com Inc. Development Team and supported by the open-source community.

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

xecd_rates_client-1.0.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xecd_rates_client-1.0.0-py2.py3-none-any.whl (4.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file xecd_rates_client-1.0.0.tar.gz.

File metadata

  • Download URL: xecd_rates_client-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for xecd_rates_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 57f0953a61cb3b72955e42a31c379c144810e7074610ea2703cad279e9fe1d9a
MD5 fb480a02e55f962b3faecfb0b3c8b2fe
BLAKE2b-256 40900a2c3914afa2c6e73cd8c2d74591c9bdd621ed0621747d03a171698b39dd

See more details on using hashes here.

File details

Details for the file xecd_rates_client-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: xecd_rates_client-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for xecd_rates_client-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1f11f291ce0acd8afa4efca1adae77c024f3ce387763f4d21091963200ca2fce
MD5 d6b1e705bf6e5f9ad79d200369dcd395
BLAKE2b-256 024f37b8311235a84bea0b2a3070e3c12ed3d8b3eaf3538661e91e73852c9349

See more details on using hashes here.

Supported by

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