mrcage/chf-exchange-rates

Retrieves Swiss Franc exchange rates for foreign currencies based on data from the website of the Swiss Federal Customs Administration.

3.0.0 2023-08-09 18:32 UTC

This package is auto-updated.

Last update: 2025-08-09 01:31:56 UTC


README

Retrieves Swiss Franc exchange rates for foreign currencies based on data from the website of the Swiss Federal Customs Administration.

https://www.estv.admin.ch/estv/en/home/value-added-tax/accounting-vat/vat-foreign-exchange-rates.html

The library uses internal caching of requested data (cache time is one week).

Usage

Include class

use MrCage\EzvExchangeRates\EzvExchangeRates;

Get exchange rate for current day

$rate = EzvExchangeRates::getExchangeRate('EUR');

Get exchange rate for a day in the past

The date must be specified as Carbon date object.

$rate = EzvExchangeRates::getExchangeRate('USD', Carbon::yesterday());

Get all available currencies

$currencies = EzvExchangeRates::listCurrencies();

This will return a list of currency codes as an array, the key being the (uppercase) currency code, and the value being the base value used for the exchange rate.