# getEvents

Clients can request a filtered list of events emitted by a given ledger range.

This method will use `10` [Compute Units](https://docs.validationcloud.io/v1/about/billing).

***

## Reference: [Here](https://soroban.stellar.org/api/methods/getEvents)

## **Parameters**

* `startLedger` *(required)*
  * Stringified ledger sequence number to fetch events after (inclusive). This method will return an error if `startLedger` is less than the oldest ledger stored in this node, or greater than the latest ledger seen by this node. If a cursor is included in the request, `startLedger` must be omitted.
* `filters`
  * array of: type (string) A comma separated list of event types (`system`, `contract`, or `diagnostic`) used to filter events. If omitted, all event types are included.
  * contractIds (array) (optional) List of contract ids to query for events. If omitted, return events for all contracts. Maximum 5 contract IDs are allowed per request.
  * topics (array) (optional) List of topic filters. If omitted, query for all events. If multiple filters are specified, events will be included if they match any of the filters. Maximum 5 filters are allowed per request.
* `pagination` (see "[Pagination](https://soroban.stellar.org/api/pagination)")

## Returns

`latestLedger` (string): Stringified-number of the current latest ledger observed by the node when this response was generated.

```bash
// Result
{
  "jsonrpc": "2.0",
  "id": 8675309,
  "result": {
    "latestLedger": "230473",
    "events": [
      {
        "type": "contract",
        "ledger": "230010",
        "ledgerClosedAt": "2023-01-23T18:54:41Z",
        "contractId": "CB64D3G7SM2RTH6JSGG34DDTFTQ5CFDKVDZJZSODMCX4NJ2HV2KN7OHT",
        "id": "0000987885427757056-0000000001",
        "pagingToken": "0000987885427757056-0000000001",
        "inSuccessfulContractCall": true,
        "topic": [
          "AAAABQAAAAh0cmFuc2Zlcg==",
          "AAAABAAAAAEAAAAAAAAAAgAAAAUAAAAHQWNjb3VudAAAAAAEAAAAAQAAAAgAAAAAHavpBsZgRv4pEDXWB0NnwQBvvAL/8adWXz2fV7eNq2o=",
          "AAAABAAAAAEAAAAAAAAAAgAAAAUAAAAHQWNjb3VudAAAAAAEAAAAAQAAAAgAAAAAHavpBsZgRv4pEDXWB0NnwQBvvAL/8adWXz2fV7eNq2o="
        ],
        "value": {
          "xdr": "AAAABAAAAAEAAAAFAAAAAAABhqAAAAAAAAAAAA=="
        }
      },
      {
        "type": "contract",
        "ledger": "230170",
        "ledgerClosedAt": "2023-01-23T19:08:37Z",
        "contractId": "CB64D3G7SM2RTH6JSGG34DDTFTQ5CFDKVDZJZSODMCX4NJ2HV2KN7OHT",
        "id": "0000988572622524416-0000000001",
        "pagingToken": "0000988572622524416-0000000001",
        "inSuccessfulContractCall": true,
        "topic": [
          "AAAABQAAAAh0cmFuc2Zlcg==",
          "AAAABAAAAAEAAAAAAAAAAgAAAAUAAAAHQWNjb3VudAAAAAAEAAAAAQAAAAgAAAAAHavpBsZgRv4pEDXWB0NnwQBvvAL/8adWXz2fV7eNq2o=",
          "AAAABAAAAAEAAAAAAAAAAgAAAAUAAAAHQWNjb3VudAAAAAAEAAAAAQAAAAgAAAAAHavpBsZgRv4pEDXWB0NnwQBvvAL/8adWXz2fV7eNq2o="
        ],
        "value": {
          "xdr": "AAAABAAAAAEAAAAFAAAAAAAHoSAAAAAAAAAAAA=="
        }
      }
    ]
  }
}
```

{% tabs %}
{% tab title="mainnet" %}

<pre class="language-bash"><code class="lang-bash"><strong>curl https://mainnet.stellar.validationcloud.io/v1/&#x3C;YOUR_API_KEY_HERE> \
</strong>    -X POST \
    -H "Content-Type: application/json" \
    -d '{
  "jsonrpc": "2.0",
  "id": 8675309,
  "method": "getEvents",
  "params": {
    "startLedger": "227000",
    "filters": [
      {
        "type": "contract",
        "contractIds": [
          "CB64D3G7SM2RTH6JSGG34DDTFTQ5CFDKVDZJZSODMCX4NJ2HV2KN7OHT"
        ],
        "topics": [
          [
            "AAAABQAAAAh0cmFuc2Zlcg==",
            "*",
            "*"
          ]
        ]
      }
    ],
    "pagination": {
      "limit": 100
    }
  }
}'
</code></pre>

{% endtab %}

{% tab title="testnet" %}

```bash
curl https://testnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{
  "jsonrpc": "2.0",
  "id": 8675309,
  "method": "getEvents",
  "params": {
    "startLedger": "227000",
    "filters": [
      {
        "type": "contract",
        "contractIds": [
          "CB64D3G7SM2RTH6JSGG34DDTFTQ5CFDKVDZJZSODMCX4NJ2HV2KN7OHT"
        ],
        "topics": [
          [
            "AAAABQAAAAh0cmFuc2Zlcg==",
            "*",
            "*"
          ]
        ]
      }
    ],
    "pagination": {
      "limit": 100
    }
  }
}'

```

{% endtab %}
{% endtabs %}
