Skip to content

Python module for requesting data from Fixer API for currency conversion

License

Notifications You must be signed in to change notification settings

jhaarden/fixer-currency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fixer Currency

A Python module for the Fixer API for currency conversion.

PyPI - Version PyPI - Python Version Github Build Status


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}}

About

Python module for requesting data from Fixer API for currency conversion

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages