> ## Documentation Index
> Fetch the complete documentation index at: https://docs.validationcloud.io/llms.txt
> Use this file to discover all available pages before exploring further.

# get_aggregate_price

Retrieves the aggregate price of specified Oracle objects, returning three price statistics: mean, median, and trimmed mean.

This method will use `20` [Compute Units](/nodeapi/about/billing).

***

## Reference: [Here](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/path-and-order-book-methods/get_aggregate_price)

## **Parameters**

* `base_asset` (string, required) The currency code of the asset to be priced.
* `quote_asset` (string, required) The currency code of the asset to quote the price of the base asset.
* `trim` (number, optional) The percentage of outliers to trim. Valid range is 1 to 25. If included, the API returns statistics for the trimmed mean.
* `trim_threshold` (number, optional) A time range in seconds for filtering out older price data. Default is 0, which does not filter any data.
* `oracles` (array, required) Between 1 and 200 oracle identifier objects, each with `account` (the account that controls the Oracle object) and `oracle_document_id` (a number).
* `ledger_hash` (string, optional) The unique hash of the ledger version to use.
* `ledger_index` (number or string, optional) The ledger index of the ledger to use, or a shortcut string such as `validated`, `closed` or `current`.

## Returns

* `entire_set` (object) Statistics from the collected oracle prices: `mean`, `size` and `standard_deviation`.
* `trimmed_set` (object) Statistics from the collected oracle prices after trimming outliers: `mean`, `size` and `standard_deviation`. Only present if `trim` was given.
* `median` (string) The median price.
* `time` (number) The most recent timestamp out of the `LastUpdateTime` values, in Unix time.
* `ledger_hash`, `ledger_index` or `ledger_current_index`, `validated` The ledger version used.

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
// Result
{
  "result": {
    "ledger_hash": "0651A1FA8B4099DFF9F3EAF4594CBA755D7F4213B20303AF4F1A37EA1DBC95B7",
    "ledger_index": 107293077,
    "validated": true,
    "time": 1790599863,
    "entire_set": {
      "mean": "1.518556044",
      "standard_deviation": "0",
      "size": 1
    },
    "median": "1.518556044",
    "trimmed_set": {
      "mean": "1.518556044",
      "standard_deviation": "0",
      "size": 1
    },
    "status": "success"
  }
}
```

<CodeGroup>
  ```bash title="mainnet" theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  curl https://mainnet.xrpl.validationcloud.io/v1/<YOUR_API_KEY_HERE> \
      -X POST \
      -H "Content-Type: application/json" \
      -d '{"method":"get_aggregate_price","params":[{"base_asset":"XRP","quote_asset":"USD","trim":20,"oracles":[{"account":"rsNvoAZ9MquZSRhu4cEY9wTv1VqHXpVPPt","oracle_document_id":1}],"ledger_index":"validated"}]}'
  ```
</CodeGroup>

Over WebSocket, send `{"id":1,"command":"get_aggregate_price","base_asset":"XRP","quote_asset":"USD","trim":20,"oracles":[{"account":"rsNvoAZ9MquZSRhu4cEY9wTv1VqHXpVPPt","oracle_document_id":1}],"ledger_index":"validated"}` to `wss://mainnet.xrpl.validationcloud.io/v1/<YOUR_API_KEY_HERE>`.

> The oracle in this example is the Band Protocol price feed on mainnet. Use `ledger_entry` with an `oracle` selector to inspect the assets an oracle publishes before aggregating. Oracle accounts that fail address validation return `invalidParams`; a valid account with no such oracle returns `objectNotFound`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.