# Advanced search API

## Elasticsearch Query

Example: Search for all `Payment` transactions with `DestinationTag` value equal to `1337`:

{% tabs %}
{% tab title="ES Query" %}

```shell
curl -XPOST 'https://console.xrpscan.com/api/v1/search' -d '
{
  "bool": {
    "must": [
      { "term": { "TransactionType": "Payment" } },
      { "term": { "DestinationTag": 1337 } }
    ]
  }
}'
```

{% endtab %}
{% endtabs %}

## Response

```json
{
  "took": 31,
  "timed_out": false,
  "_shards": {
    "total": 98,
    "successful": 98,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 7382,
      "relation": "eq"
    },
    "max_score": null,
    "hits": [
      {
        "_index": "platform.xrpl.transactions-97m",
        "_id": "F2E402B43EDE6EA9E7BD87CDCAA4236834E89236F8ACB3445F558534741C3012",
        "_score": 1.4392471,
        "_source": {
          "Account": "rJHkpNJVRUKMGV3NV6FNccySKNwEFF9C4c",
          "Amount": {
            "_currency": "XRP",
            "_value": 176032.226409,
            "currency": "XRP",
            "native": true,
            "value": "176032226409"
          },
          "DeliverMax": {
            "_currency": "XRP",
            "_value": 176032.226409,
            "currency": "XRP",
            "native": true,
            "value": "176032226409"
          },
          "Destination": "rLHzPsX6oXkzU2qL12kHCH8G8cnZv1rBJh",
          "DestinationTag": 1337,
          "Fee": 24,
                    "Flags": 2147483648,
          "LastLedgerSequence": 97359736,
          "Sequence": 89292640,
          "SigningPubKey": "02ED1CCA3DBC1971D38E72ECF74452739C9A4FD8C77EC2E3C5C4561371BF7B1ADF",
          "TransactionType": "Payment",
          "TxnSignature": "304502210097F5922FA7E0EF817EA5FC678A82766798C3BE0AAC636A2CACE846A98CBED83A02206BC6D2CB3ED8E8E5306D342063549C2BC16F6421B87AA80AAAA9D1F4E457E
619",
          "_Fee": 0.000024,
          "_date": "2025-07-08T12:02:02Z",
          "ctid": "C5CD330800420000",
          "date": 805291322,
          "hash": "F2E402B43EDE6EA9E7BD87CDCAA4236834E89236F8ACB3445F558534741C3012",
          "ledger_index": 97334024,
          "meta": {
            "TransactionIndex": 66,
            "TransactionResult": "tesSUCCESS",
            "delivered_amount": {
              "_currency": "XRP",
              "_value": 176032.226409,
              "currency": "XRP",
              "native": true,
              "value": "176032226409"
            }
          },
          "validated": true
        },
        "sort": [
          97334024,
          1.4392471
        ]
      },
      ...
      ...
    ]
  }
}
```

## SQL Query

The advanced search API also supports limited SQL queries. Example: Search all transactions where `DestinationTag` = 1337

{% tabs %}
{% tab title="Elasticsearch SQL" %}

```javascript
curl -XPOST 'https://console.xrpscan.com/api/v1/sql' -d '
{
  "format": "text",
  "query": "SELECT ctid, Account, Destination, DestinationTag FROM \"platform.xrpl.transactions\" WHERE DestinationTag = 1337 LIMIT 10"
}
'
```

{% endtab %}
{% endtabs %}

The `format` parameter supports following values: `csv` `json` `tsv` `txt` `text` `yaml` `cbor` `smile`.

## Response

```
      ctid      |             Account              |           Destination            |DestinationTag
----------------+----------------------------------+----------------------------------+---------------
C2356DB500090000|rJb5KsHsDHF1YS5B5DU6QCkH5NsPaKQTcy|rDGfU2vjzieWac1drAvLKge8hQLPK7Wgcy|1337
C4E453B300080000|rpz1PivxjVPbuF8yUsBqj1kk6y7NaQLLQt|rNhUFBAAZagSP91YRQA7sxjMMVHQS3GbZE|1337
C502D19300060000|rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy|rNdzyWuUChAcdRzSnTKT3SbWcdDSZLfrun|1337
C235D16A00110000|rJb5KsHsDHF1YS5B5DU6QCkH5NsPaKQTcy|rDGfU2vjzieWac1drAvLKge8hQLPK7Wgcy|1337
C32A699B00280000|rfwWwz7yrvBCVY1RWdnZ4Uk1va7WpiWxNX|rJ3MkSEBzjkQdecHUr6svQwwTX79WEE2gd|1337
C284C741000B0000|rG8orpd1A58Tk5j3Atx9WEizt2AFW4THCT|rsCSfPvKsFmiRBcDUo8tU2vx96nuSes7Vx|1337
C4E44FE400060000|rLSn6Z3T8uCxbcd1oxwfGQN1Fdn5CyGujK|rNhUFBAAZagSP91YRQA7sxjMMVHQS3GbZE|1337
C4E4506400110000|rLSn6Z3T8uCxbcd1oxwfGQN1Fdn5CyGujK|rNhUFBAAZagSP91YRQA7sxjMMVHQS3GbZE|1337
C4E450CA002A0000|rLSn6Z3T8uCxbcd1oxwfGQN1Fdn5CyGujK|rNhUFBAAZagSP91YRQA7sxjMMVHQS3GbZE|1337
C235D1C700370000|rPdvC6ccq8hCdPKSPJkPmyZ4Mi1oG2FFkT|rQHYSEyxX3GKK3F6sXRvdd2NHhUqaxtC6F|1337
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xrpscan.com/advanced-search/advanced-search-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
