ledger_entry

[Source]

Attention

Price Oracle functionality is part of the proposed XLS-47d extension to the XRP Ledger protocol. You can use these functions on test networks for now. Until there is an amendment in a stable release, the details documented on these pages are subject to change.

You can use the existing ledger_entry method to retrieve an Oracle instance.

Request Format

An example of the request format:

{
  "method": "ledger_entry",
  "params" : [
    {
      "oracle" : {
        "account": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
        "oracle_document_id":  34,
      },
      "ledger_index": "validated"
    }
  ]
}

The request contains the following parameters:

FieldTypeRequired?Description
oracleObjectYesThe oracle identifier.
oracle.accountStringYesThe XRPL account that controls the Oracle object.
oracle.oracle_document_idNumberYesA unique identifier of the price oracle for the Account. The Oracle Document ID is maintained by the Oracle Provider.

Response Format

An example of the response format:

{
  "index" : "CF2C20122022DE908C4F521A96DC2C1E5EFFD1EFD47AA244E9EE9A442451162E",
  "ledger_current_index" : 23,
  "node" : {
    "Flags" : 0,
    "LastUpdateTime" : 743609014,
    "LedgerEntryType" : "Oracle",
    "Owner" : "rp847ow9WcPmnNpVHMQV5A4BF6vaL9Abm6",
    "AssetClass" : "63757272656E6379",
    "Provider": "70726F7669646572",
    "PreviousTxnID" : "6F120537D0D212FEA6E11A0DCC5410AFCA95BD98D451D046832E6C4C4398164D",
    "PreviousTxnLgrSeq" : 22,
    "PriceDataSeries": [
      {
        "PriceData": {
          "QuoteAsset" : {
             "currency" : "USD"
          },
          "BaseAsset" : {
             "currency" : "XRP"
          },
          "Scale" : 1,
          "AssetPrice" : "740",
        }
      }
    ],
    "index" : "CF2C20122022DE908C4F521A96DC2C1E5EFFD1EFD47AA244E9EE9A442451162E"
  },
  "status" : "success",
  "validated" : true
}

The response follows the standard format, with a successful result containing the following fields:

FieldTypeDescription
LastUpdateTimeNumberThe time the data was last updated, represented in Unix time.
OwnerStringThe XRPL account with update and delete privileges for the oracle.
AssetClassStringDescribes the type of asset, such as "currency", "commodity", or "index".
ProviderStringThe oracle provider, such as Chainlink, Band, or DIA.
PreviousTxnIDStringThe hash of the previous transaction that modified this entry.
PreviousTxnLgrSeqStringThe ledger index that this object was most recently modified or created in.
PriceDataSeriesArrayAn array of up to 10 PriceData objects.

PriceData Object

FieldTypeDescription
BaseAssetObjectThe primary asset in a trading pair.
BaseAsset.currencyStringThe base asset currency code, conformant to the XRPL currency codes format.
QuoteAssetObjectThe quote asset in a trading pair. The quote asset denotes the price of one unit of the base asset.
QuoteAsset.currencyStringThe quote asset currency code, conformant to the XRPL currency codes format.
AssetPriceStringThe asset price after applying the Scale precision level. This field isn't included if the last update transaction didn't include the BaseAsset/QuoteAsset pair.
ScaleNumberThe scaling factor to apply to an asset price. For example, if Scale is 6 and original price is 0.155, then the scaled price is 155000. This field isn't included if the last update transaction didn't include the BaseAsset/QuoteAsset pair.

Note: Token pairs that appear without AssetPrice and Scale signify the price is outdated.