KosmoKrator

data

ExchangeRate Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the ExchangeRate KosmoKrator integration.

Lua Namespace

Agents call this integration through app.integrations.exchangerate.*. Use lua_read_doc("integrations.exchangerate") inside KosmoKrator to discover the same reference at runtime.

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic ExchangeRate workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.exchangerate.list_currencies({query = "example_query"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("exchangerate"))' --json
kosmo integrations:lua --eval 'print(docs.read("exchangerate.list_currencies"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local exchangerate = app.integrations.exchangerate
local result = exchangerate.list_currencies({query = "example_query"})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.exchangerate, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.exchangerate.default.* or app.integrations.exchangerate.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need ExchangeRate, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Exchange Rate — Lua API Reference

No API key needed. Uses the public Fawaz Ahmed exchange-api datasets and supports fiat, crypto, and precious metals.

convert_currency

Convert an amount from one currency to another.

NameTypeRequiredDescription
fromstringyesSource currency code (e.g. "usd", "btc", "xau")
tostringyesTarget currency code (e.g. "eur", "jpy")
amountstringnoAmount to convert (default: "1")
datestringnoDate for the rate: "YYYY-MM-DD" or "latest" (default)
local result = app.integrations.exchangerate.convert_currency({
  from = "usd",
  to = "eur",
  amount = "100"
})

print("100 USD = " .. result.result .. " EUR")

pair_rate

Get the direct exchange rate for one currency pair without downloading the full base-currency matrix.

NameTypeRequiredDescription
fromstringyesSource currency code (e.g. "usd", "btc", "xau")
tostringyesTarget currency code (e.g. "eur", "jpy")
datestringnoDate for the rate: "YYYY-MM-DD" or "latest" (default)
local result = app.integrations.exchangerate.pair_rate({
  from = "usd",
  to = "eur"
})

print(result.rate)

history

Compare a currency pair across multiple dates.

NameTypeRequiredDescription
fromstringyesSource currency code
tostringyesTarget currency code
datesstringyesComma-separated dates (e.g. "2026-01-01,2026-02-01,2026-03-01")
local result = app.integrations.exchangerate.history({
  from = "usd",
  to = "eur",
  dates = "2026-01-01,2026-02-01,2026-03-01"
})

for _, h in ipairs(result.history) do
  print(h.date .. ": " .. h.rate)
end
-- result.change.percentage shows overall change

list_currencies

List and search available currencies.

NameTypeRequiredDescription
querystringnoFilter by code or name (e.g. "dollar", "btc", "gold")
local result = app.integrations.exchangerate.list_currencies({ query = "gold" })

for _, c in ipairs(result.currencies) do
  print(c.code .. ": " .. c.name)
end

rates

Get all exchange rates for a base currency.

NameTypeRequiredDescription
basestringyesBase currency code (e.g. "usd")
currenciesstringnoComma-separated codes to filter (e.g. "eur,gbp,jpy")
datestringnoDate for the rate: "YYYY-MM-DD" or "latest" (default)
local result = app.integrations.exchangerate.rates({
  base = "usd",
  currencies = "eur,gbp,jpy"
})

Show commonly used currency codes. No parameters.

local result = app.integrations.exchangerate.popular_currencies({})

Examples

Convert 500 EUR to USD

local result = app.integrations.exchangerate.convert_currency({
  from = "eur",
  to = "usd",
  amount = "500"
})

Historical rate on a specific date

local result = app.integrations.exchangerate.convert_currency({
  from = "gbp",
  to = "jpy",
  amount = "1",
  date = "2025-06-15"
})

Track EUR/USD over several months

local result = app.integrations.exchangerate.history({
  from = "eur",
  to = "usd",
  dates = "2025-10-01,2025-11-01,2025-12-01,2026-01-01,2026-02-01,2026-03-01"
})

print("Change: " .. result.change.percentage .. "%")

Find a currency code

local result = app.integrations.exchangerate.list_currencies({ query = "peso" })
-- Returns matching currencies like MXN (Mexican Peso), ARS (Argentine Peso), etc.
Raw agent markdown
# Exchange Rate — Lua API Reference

No API key needed. Uses the public Fawaz Ahmed exchange-api datasets and supports fiat, crypto, and precious metals.

## convert_currency

Convert an amount from one currency to another.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `from` | string | yes | Source currency code (e.g. `"usd"`, `"btc"`, `"xau"`) |
| `to` | string | yes | Target currency code (e.g. `"eur"`, `"jpy"`) |
| `amount` | string | no | Amount to convert (default: `"1"`) |
| `date` | string | no | Date for the rate: `"YYYY-MM-DD"` or `"latest"` (default) |

```lua
local result = app.integrations.exchangerate.convert_currency({
  from = "usd",
  to = "eur",
  amount = "100"
})

print("100 USD = " .. result.result .. " EUR")
```

## pair_rate

Get the direct exchange rate for one currency pair without downloading the full base-currency matrix.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `from` | string | yes | Source currency code (e.g. `"usd"`, `"btc"`, `"xau"`) |
| `to` | string | yes | Target currency code (e.g. `"eur"`, `"jpy"`) |
| `date` | string | no | Date for the rate: `"YYYY-MM-DD"` or `"latest"` (default) |

```lua
local result = app.integrations.exchangerate.pair_rate({
  from = "usd",
  to = "eur"
})

print(result.rate)
```

## history

Compare a currency pair across multiple dates.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `from` | string | yes | Source currency code |
| `to` | string | yes | Target currency code |
| `dates` | string | yes | Comma-separated dates (e.g. `"2026-01-01,2026-02-01,2026-03-01"`) |

```lua
local result = app.integrations.exchangerate.history({
  from = "usd",
  to = "eur",
  dates = "2026-01-01,2026-02-01,2026-03-01"
})

for _, h in ipairs(result.history) do
  print(h.date .. ": " .. h.rate)
end
-- result.change.percentage shows overall change
```

## list_currencies

List and search available currencies.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `query` | string | no | Filter by code or name (e.g. `"dollar"`, `"btc"`, `"gold"`) |

```lua
local result = app.integrations.exchangerate.list_currencies({ query = "gold" })

for _, c in ipairs(result.currencies) do
  print(c.code .. ": " .. c.name)
end
```

## rates

Get all exchange rates for a base currency.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `base` | string | yes | Base currency code (e.g. `"usd"`) |
| `currencies` | string | no | Comma-separated codes to filter (e.g. `"eur,gbp,jpy"`) |
| `date` | string | no | Date for the rate: `"YYYY-MM-DD"` or `"latest"` (default) |

```lua
local result = app.integrations.exchangerate.rates({
  base = "usd",
  currencies = "eur,gbp,jpy"
})
```

## popular_currencies

Show commonly used currency codes. No parameters.

```lua
local result = app.integrations.exchangerate.popular_currencies({})
```

## Examples

### Convert 500 EUR to USD

```lua
local result = app.integrations.exchangerate.convert_currency({
  from = "eur",
  to = "usd",
  amount = "500"
})
```

### Historical rate on a specific date

```lua
local result = app.integrations.exchangerate.convert_currency({
  from = "gbp",
  to = "jpy",
  amount = "1",
  date = "2025-06-15"
})
```

### Track EUR/USD over several months

```lua
local result = app.integrations.exchangerate.history({
  from = "eur",
  to = "usd",
  dates = "2025-10-01,2025-11-01,2025-12-01,2026-01-01,2026-02-01,2026-03-01"
})

print("Change: " .. result.change.percentage .. "%")
```

### Find a currency code

```lua
local result = app.integrations.exchangerate.list_currencies({ query = "peso" })
-- Returns matching currencies like MXN (Mexican Peso), ARS (Argentine Peso), etc.
```
Metadata-derived Lua example
local result = app.integrations.exchangerate.list_currencies({query = "example_query"})
print(result)

Functions

list_currencies Read

List all available currencies (fiat, crypto, precious metals, stablecoins). Supports 340+ assets. Optionally filter by name or code.

Lua path
app.integrations.exchangerate.list_currencies
Full name
exchangerate.exchangerate_list_currencies
ParameterTypeRequiredDescription
query string no Filter currencies by code or name (e.g. "dollar", "btc", "gold").
convert_currency Read

Convert an amount from one currency to another. Supports 340 fiat currencies, cryptocurrencies, and precious metals. Common codes: usd, eur, gbp, jpy, cny, chf, cad, aud, btc, eth, sol, xau, xag.

Lua path
app.integrations.exchangerate.convert_currency
Full name
exchangerate.exchangerate_convert_currency
ParameterTypeRequiredDescription
from string yes Source currency code (e.g. "usd", "btc", "xau").
to string yes Target currency code (e.g. "eur", "jpy").
amount string no Amount to convert (default: "1").
date string no Date for the rate (default: "latest"). Format: "YYYY-MM-DD" or "latest".
pair Read

Get the direct exchange rate for one currency pair using the upstream pair endpoint. Supports latest and historical dates.

Lua path
app.integrations.exchangerate.pair
Full name
exchangerate.exchangerate_pair_rate
ParameterTypeRequiredDescription
from string yes Source currency code (e.g. "usd", "btc", "xau").
to string yes Target currency code (e.g. "eur", "jpy").
date string no Date for the rate (default: "latest"). Format: "YYYY-MM-DD" or "latest".
exchange_rates Read

Get all exchange rates for a base currency. Optionally filter to specific target currencies. Supports 340 fiat currencies, cryptocurrencies, and precious metals.

Lua path
app.integrations.exchangerate.exchange_rates
Full name
exchangerate.exchangerate_rates
ParameterTypeRequiredDescription
base string yes Base currency code (e.g. "usd", "btc").
date string no Date for rates (default: "latest"). Format: "YYYY-MM-DD" or "latest".
currencies string no Comma-separated currency codes to filter (e.g. "eur,gbp,jpy"). Shows popular currencies if omitted.
history Read

Compare a currency pair across multiple dates to see rate changes over time. Returns each date's rate and the overall change.

Lua path
app.integrations.exchangerate.history
Full name
exchangerate.exchangerate_history
ParameterTypeRequiredDescription
from string yes Source currency code (e.g. "usd", "btc", "xau").
to string yes Target currency code (e.g. "eur", "jpy").
dates string yes Comma-separated dates to compare (e.g. "2026-01-01,2026-02-01,2026-02-20").