Method

price.fetchQuotes

Start a Quote fetch of online prices; returns its ID at once.

Starts fetching online prices for commodities that have a quote source, and returns a fetch ID at once; poll price.fetchStatus for the outcome. With no commodities it fetches every commodity GnuCash would (its quote flag on and a supported source); namespace limits it to a namespace.

The network is off by default: until the Configuration setting quotes.network is true the call fails with network-disabled and sends nothing. A person turns it on with config.set; over MCP the setting cannot be changed.

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":"price.fetchQuotes","params":{}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": 5000,
    "message": "…",
    "data": {
      "help": "error/network-disabled"
    }
  }
}

Command line

red-ale exec --book book.gnucash price.fetchQuotes

It fails with exit status 2, printing on standard error:

{
  "error": {
    "code": 5000,
    "message": "…",
    "data": {
      "help": "error/network-disabled"
    }
  }
}

MCP tool call

Tool call:

{"name":"price.fetchQuotes","arguments":{}}

Result:

{
  "isError": true,
  "structuredContent": {
    "error": {
      "code": 5000,
      "name": "network-disabled",
      "message": "…",
      "data": {
        "help": "error/network-disabled"
      }
    }
  }
}

Effect: write, on the Book.

Params

Params of price.fetchQuotes.

  • commodities (array of CommodityId or null): Fetch these, whatever their quote flag; each needs a quote source (a currency has currency). Default: every commodity with quotes on and a quote source.
  • namespace (string or null): Only commodities in namespaces matching this pattern, case-insensitive and unanchored, as gnucash-cli --namespace. Not with commodities.

Result

What price.fetchQuotes started.

  • fetch (string, required): The Quote fetch's ID, for price.fetchStatus.
  • commodities (array of CommodityId, required): The commodities it covers, in the order fetched.