A Python client for Fixer API - a currency conversion API
Project description
Fixer Currency
A Python module for the Fixer API for currency conversion.
Table of Contents
Module Description
Fixer API (formerly known as Fixer.io) is a JSON API for current and historical foreign exchange rates published by the European Central Bank.
The rates are updated daily around 13:00 CET.
This module is based on the module fixerio originally created by by Adrián Matellanes.
Installation
pip install fixer-currency
License
fixer-currency
is distributed under the terms of the MIT license.
Account and API Key
All calls to the Fixer API requires an API key. To acquire an API key you need to first register for an account on API Layer. When logged in, go to the Fixer API page and subscribe to one of the plans. The free plan allows for quite a number of requests per month and has no other restrictions as to what can be requested through the API.
Usage
All requests to the Fixer API should be made using an instance of the FixerClient
class.
from fixer_currency import FixerClient
fxr = FixerClient("<YOUR API KEY>")
The FixerClient
object always has a base currency defined for conversions and
the default currency is EUR. Another base currency can be specified with an
argument:
fxr = FixerClient("<YOUR API KEY>", "USD")
List all available currencys that can be used as base or target in a conversion:
>>> fxr.available_currencies()
{'success': True, 'symbols': {'AED': 'United Arab Emirates Dirham', 'AFN': 'Afghan Afghani', 'ALL': 'Albanian Lek', ... }}
Get latest rate(s) for one or more currencies:
>>> fxr.latest(symbols=["SEK", "NOK"])
{'success': True, 'timestamp': 1692526623, 'base': 'EUR', 'date': '2023-08-20', 'rates': {'SEK': 11.938802, 'NOK': 11.611995}}
Get historical rates for any day since 1999:
>>> import datetime
>>> fxr.historical_rates(datetime.date(2022, 1,1), symbols="SEK")
{'success': True, 'timestamp': 1641081599, 'historical': True, 'base': 'EUR', 'date': '2022-01-01', 'rates': {'SEK': 10.291223}}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for fixer_currency-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8b20c36dbc9fbbd627f2a26cfba2832c5d3cdd38eb6d850eda71783f7cd2d88 |
|
MD5 | a7d902c80af4237c3e5670f8b3656236 |
|
BLAKE2b-256 | 46413f99373a3c6857bba65fa22da1c1caab2554b4a7f4439e8b5e1c9851e64f |