Skip to main content

A Python client for Fixer API - a currency conversion API

Project description

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

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

fixer_currency-0.1.0.tar.gz (12.6 kB view hashes)

Uploaded Source

Built Distribution

fixer_currency-0.1.0-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

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