https://github.com/spoje-net/cnb-cache
https://github.com/spoje-net/cnb-cache
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/spoje-net/cnb-cache
- Owner: Spoje-NET
- License: mit
- Created: 2025-01-21T23:23:58.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-25T22:29:01.000Z (over 1 year ago)
- Last Synced: 2025-01-25T23:29:32.372Z (over 1 year ago)
- Language: PHP
- Size: 3.3 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CNB cache

[](https://php.net/)
[](https://opensource.org/licenses/MIT)
[](https://github.com/vitexsoftware/cnb-cache/releases)
Store daily currency rates in SQL database for given time.
Provide simple API like web interface for stored rates obtaining.
## Installation
```shell
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:

First Configure the currencies to be cached

Then set the days to keep the cache

And finally the cache is initialized:

Data stored in 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:
* `currency` - currency code (default: CZK)
* `when` - date of rate (default: today)
* `date` - date of rate in format YYYY-MM-DD
* `age` - age of rate in days (default: 0)
* `when` - yesterday, beforeyesterday - today is default
* - todays EUR rate
* - yesterday $ rate
```json
{
"id": 6,
"date": "2025-01-24",
"currency": "dolar",
"amount": 1,
"code": "USD",
"rate": 23.958,
"age": 2
}
```
The systemd-crond service is started and the cache is updated every day at 0:01 AM
See also: https://github.com/Spoje-NET/pohoda-raiffeisenbank