commodity.list
List commodities: the book's own and the built-in ISO 4217 currencies.
Lists commodities, sorted by namespace and then mnemonic: the book's own and every built-in currency it does not
define. namespace limits the list to one namespace; usedOnly keeps only those something in the book refers to
(an account, a transaction currency, a price, a business object). Each entry says how much of the book uses it.
Examples
Example: with a copy of the reports/test-data example book open as book.gnucash.
JSON-RPC
Request:
{"jsonrpc":"2.0","id":1,"method":"commodity.list","params":{"usedOnly":true}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"id": "CURRENCY::GBP",
"fullname": "Pound Sterling",
"fraction": 100,
"isCurrency": true,
"usage": {
"accounts": 2,
"transactions": 13,
"prices": 2,
"business": 0
},
"…": "…"
},
{
"id": "CURRENCY::USD",
"fullname": "US Dollar",
"fraction": 100,
"usage": {
"accounts": 8,
"transactions": 46,
"prices": 2,
"business": 0
},
"…": "…"
}
]
}
Command line
red-ale exec --book book.gnucash commodity.list '{"usedOnly":true}'
It prints:
[
{
"id": "CURRENCY::GBP",
"fullname": "Pound Sterling",
"fraction": 100,
"isCurrency": true,
"usage": {
"accounts": 2,
"transactions": 13,
"prices": 2,
"business": 0
},
"…": "…"
},
{
"id": "CURRENCY::USD",
"fullname": "US Dollar",
"fraction": 100,
"usage": {
"accounts": 8,
"transactions": 46,
"prices": 2,
"business": 0
},
"…": "…"
}
]
MCP tool call
Tool call:
{"name":"commodity.list","arguments":{"usedOnly":true}}
Result:
{
"content": [
{
"type": "text",
"text": "[{\"id\":\"CURRENCY::GBP\",\"fullname\":\"Pound Sterling\",\"fraction\":100,\"isCurrency\":true,\"usage\":{\"accounts\":2,\"transactions\":13,\"prices\":2,\"business\":0},\"…\":\"…\"},{\"id\":\"CURRENCY::USD\",\"fullname\":\"US Dollar\",\"fraction\":100,\"usage\":{\"accounts\":8,\"transactions\":46,\"prices\":2,\"business\":0},\"…\":\"…\"}]"
}
]
}
Effect: read.
Params
Params of commodity.list.
namespace(string or null): Only this namespace (CURRENCYfor the currencies).usedOnly(boolean): Only commodities something in the book uses.
Result
Type: array of CommodityInfo.