---
title: "Stream Soroban smart-contract events over a ledger range"
method: POST
path: "/?stellar_getEvents"
tags: ["Stellar (Soroban) API"]
---

# Stream Soroban smart-contract events over a ledger range

`POST /?stellar_getEvents`

## Request

- Base URL: `https://rpc.ankr.com/multichain/569ca1f392f7d3d0bb1073a1173ecb649af1d9249231fe59fa95db19d5ae41fe`
- URL: `https://rpc.ankr.com/multichain/569ca1f392f7d3d0bb1073a1173ecb649af1d9249231fe59fa95db19d5ae41fe/?stellar_getEvents`
- Auth: none declared
- TypeScript: <https://skmtc.dev/ankr/apis/ankr-advanced-api/docs/%3Fstellar_getEvents/post.ts> (a function with typed inputs; its response is checked against the schema)

Returns Soroban contract events, filtered by type, contract and topic pattern over a ledger range. This method has no EVM counterpart: Soroban events carry base64 XDR `ScVal` topics rather than hex log topics.

Topic patterns match segment by segment, `*` matches exactly one segment and `**` matches zero or more segments at the end. Paginate with the `cursor` from the previous reply; `latestLedger` tells you how far the index has reached.

Stellar is served by this namespace only. The `ankr_*` methods reject both `stellar` and `stellar_soroban` as a `blockchain` value.

## Request body

- object
  - `id` integer, required: Client-supplied request ID echoed in the response.
  - `jsonrpc` '2.0', required
  - `method` 'stellar_getEvents', required
  - `params` object, required
    - `blockchain` 'stellar_soroban', required: Stellar network identifier.
    - `startLedger` integer, required: First ledger sequence number to read.
    - `endLedger` integer: Last ledger sequence number to read.
    - `limit` integer: Maximum number of events to return.
    - `cursor` string: Pagination cursor from a prior response.
    - `filters` object[]: Event filters. An event matches when it satisfies any one filter.
      - `type` 'contract' | 'system' | 'diagnostic'
      - `contractIds` string[]: Strkey contract addresses (`C…`) to match.
      - `topics` array[]: Topic patterns, each a list of base64 XDR ScVal segments. `*` matches one segment, `**` matches zero or more at the end.
        - string[]

## Response `200`

Success. JSON-RPC `result` contains the matching events, a pagination cursor and the latest indexed ledger. JSON-RPC errors are returned with HTTP 200; check the response body for an `error` key.

- object
  - `id` integer, required
  - `jsonrpc` '2.0', required
  - `result` object, required
    - `events` object[], required
      - `type` 'contract' | 'system' | 'diagnostic'
      - `ledger` integer
      - `ledgerClosedAt` string: Ledger close time, RFC 3339.
      - `contractId` string: Strkey address of the emitting contract.
      - `id` string
      - `pagingToken` string
      - `topic` string[]: Topic segments as base64 XDR ScVal.
      - `value` string: Event body as base64 XDR ScVal.
      - `inSuccessfulContractCall` boolean
      - `txHash` string
    - `cursor` string: Pass back as `cursor` to continue from the last event.
    - `latestLedger` integer: Latest ledger the index has reached.

## Other responses

- `400`: Bad Request — malformed JSON-RPC envelope or invalid `params`. The gateway rejects before the JSON-RPC layer processes the call.
- `401`: Unauthorized — missing or invalid API key in the server URL path. Verify that `{API_KEY}` is set to a valid project key.
- `429`: Too Many Requests — the API key has exceeded its rate or quota limits. Back off and retry; consider upgrading the Premium tier for higher limits.
- `500`: Server error — unexpected condition. Retry with exponential backoff; if it persists, file a ticket at https://www.ankr.com/support/.

---

[API](https://skmtc.dev/ankr/apis/ankr-advanced-api.md) - [All operations](https://skmtc.dev/ankr/apis/ankr-advanced-api/llms.txt) - [OpenAPI document](https://skmtc.dev/ankr/apis/ankr-advanced-api/revisions/77e494aeec1b?raw)
