Skip to content
Spoje-NETPublic

About

keep daily currency rates from ČNB

Topics

Resources

Stars

1 star

Watchers

3 watching

Forks

Repository files navigation

CNB cache

cnb-cache Packaging: deb

PHP Version License Latest Release

Store daily currency rates in SQL database for given time.

Provide simple API like web interface for stored rates obtaining.

Installation

sudo apt install lsb-release wget apt-transport-https bzip2


wget -qO- https://repo.vitexsoftware.com/keyring.gpg | sudo tee /etc/apt/trusted.gpg.d/vitexsoftware.gpg
echo "deb [signed-by=/etc/apt/trusted.gpg.d/vitexsoftware.gpg]  https://repo.vitexsoftware.com  $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vitexsoftware.list
sudo apt update

sudo apt install cnb-cache-DATABASE

database can be mysql or sqlite

Support the apache2 and lighthttpd web servers:

Web Servers

First Configure the currencies to be cached

Currency Chooser

Then set the days to keep the cache

Days to Keep

And finally the cache is initialized:

Initialization

Data stored in database:

Database

Final configuration is stored in /etc/cnb-cache/cnb-cache.env file

Data Obtaining

After installation the currencies listing is available on the /cnb-cache/ path.

you can use following URL parameters:

{
  "id": 6,
  "date": "2025-01-24",
  "currency": "dolar",
  "amount": 1,
  "code": "USD",
  "rate": 23.958,
  "age": 2,
  "published": "2025-01-24"
}

published is the day of the CNB list the rate comes from. CNB publishes on working days after 14:30 and the list is valid until the next one, so on weekends, holidays and before publication it is older than date. A rate which is not final yet is returned but not cached. Unknown or unconfigured currency returns HTTP 404.

The systemd timer updates the cache at 0:01 and on working days at 14:45 and 15:30 (Prague time).

See also: https://github.com/Spoje-NET/pohoda-raiffeisenbank

About

keep daily currency rates from ČNB

Topics

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages