id: exchange-rates-ntfy-report
namespace: company.reporting
description: |
Fetches the latest exchange rates from the free Frankfurter API (ECB data), saves them
into a CSV file, summarizes them with DuckDB and sends the report as a push notification
through ntfy.sh. No password, no account, no secrets.
inputs:
- id: base
type: STRING
defaults: EUR
description: Base currency (ISO 4217 code).
- id: symbols
type: STRING
defaults: HUF,USD,GBP,CHF,PLN
description: Comma-separated list of currencies to compare against the base.
- id: ntfy_topic
type: STRING
defaults: kestra-fx-change-this-to-something-unique-4821
description: Your private topic name on ntfy.sh. Anyone who knows the name can
read it, so make it long and random.
- id: force_notify
type: BOOL
defaults: false
description: Send the notification even if the ECB has not published new rates
today (useful for manual test runs).
triggers:
- id: weekday_schedule
type: io.kestra.plugin.core.trigger.Schedule
description: Every weekday at 16:30 Budapest time, after the ECB publishes its
daily rates.
cron: "30 16 * * 1-5"
timezone: Europe/Budapest
disabled: false
tasks:
- id: fetch_rates
type: io.kestra.plugin.core.http.Request
description: Gets the latest rates from the Frankfurter API.
uri: "https://api.frankfurter.dev/v1/latest?base={{ inputs.base }}&symbols={{
inputs.symbols }}"
method: GET
retry:
type: exponential
interval: PT2S
maxInterval: PT30S
maxAttempts: 3
- id: log_report
type: io.kestra.plugin.core.log.Log
description: Writes the rates into the execution log.
message: |
Exchange rates for {{ fromJson(outputs.fetch_rates.body).date }} (base: {{ inputs.base }})
{%- for entry in fromJson(outputs.fetch_rates.body).rates %}
{{ inputs.base }}/{{ entry.key }}: {{ entry.value }}
{%- endfor %}
- id: save_csv
type: io.kestra.plugin.core.storage.Write
description: Saves the rates into a CSV file in internal storage.
extension: .csv
content: |
date,base,currency,rate
{%- for entry in fromJson(outputs.fetch_rates.body).rates %}
{{ fromJson(outputs.fetch_rates.body).date }},{{ inputs.base }},{{ entry.key }},{{ entry.value }}
{%- endfor %}
- id: summarize_rates
type: io.kestra.plugin.jdbc.duckdb.Query
description: Finds the highest and lowest rate in the CSV with an in-memory
DuckDB query.
inputFiles:
rates.csv: "{{ outputs.save_csv.uri }}"
sql: |
SELECT
count(*) AS currencies,
arg_max(currency, rate) AS highest_currency,
max(rate) AS highest_rate,
arg_min(currency, rate) AS lowest_currency,
min(rate) AS lowest_rate
FROM read_csv_auto('{{ workingDir }}/rates.csv');
fetchType: FETCH_ONE
- id: check_fresh_rates
type: io.kestra.plugin.core.flow.If
description: Notifies only when the ECB published rates today, or when
force_notify is true.
condition: "{{ inputs.force_notify or fromJson(outputs.fetch_rates.body).date ==
now(format='yyyy-MM-dd', timeZone='Europe/Budapest') }}"
then:
- id: send_notification
type: io.kestra.plugin.core.http.Request
description: Publishes the report to your ntfy.sh topic as a push notification.
uri: "https://ntfy.sh/{{ inputs.ntfy_topic }}"
method: POST
contentType: text/plain
headers:
Title: "Exchange rates {{ fromJson(outputs.fetch_rates.body).date }}"
Tags: chart_with_upwards_trend
body: |
Base: {{ inputs.base }}
{%- for entry in fromJson(outputs.fetch_rates.body).rates %}
{{ entry.key }}: {{ entry.value }}
{%- endfor %}
Highest: {{ outputs.summarize_rates.row.highest_currency }} ({{ outputs.summarize_rates.row.highest_rate }})
Lowest: {{ outputs.summarize_rates.row.lowest_currency }} ({{ outputs.summarize_rates.row.lowest_rate }})
else:
- id: log_stale_rates
type: io.kestra.plugin.core.log.Log
level: WARN
message: "No new ECB rates today (latest data is from {{
fromJson(outputs.fetch_rates.body).date }}). Notification skipped."
outputs:
- id: rates_file
type: FILE
description: CSV file with the fetched exchange rates.
value: "{{ outputs.save_csv.uri }}"