---
title: "Query historical contract logs filtered by address, topic, and block range"
method: POST
path: "/?ankr_getLogs"
tags: ["Query API"]
---

# Query historical contract logs filtered by address, topic, and block range

`POST /?ankr_getLogs`

## Request

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

Returns indexed contract logs (events) for the requested chain and block range. Standard `eth_getLogs` semantics, plus multi-chain dispatch, pagination, and optional event-signature decoding via `decodeLogs: true`.

Pass `blockchain` and either a block range (`fromBlock` / `toBlock`) or a time range (`fromTimestamp` / `toTimestamp`). Scope by `address` (single or array of contracts) and / or `topics` (nested arrays matching `eth_getLogs` topic filter semantics). Paginate with `pageSize` (default `1000`, max `10000`) and `pageToken`.

Part of the **Query API** product (700 compute units per call, $0.00007 at base rate).

## Request body

- object
  - `id` integer, required: Client-supplied request ID echoed in the response.
  - `jsonrpc` '2.0', required
  - `method` 'ankr_getLogs', required
  - `params` object, required
    - `blockchain` string[]: Chains to query. Omit or pass an empty array to query all supported chains.
    - `address` string[]: Contract address(es) to scope logs to.
    - `fromBlock` union: Start block (integer, hex, or `earliest`).
      - integer
      - string
    - `toBlock` union: End block (integer, hex, or `latest`).
      - integer
      - string
    - `fromTimestamp` integer: UNIX timestamp lower bound.
    - `toTimestamp` integer: UNIX timestamp upper bound.
    - `topics` array[]: Topic filter — array of arrays of 32-byte topic hashes, matching `eth_getLogs` semantics.
      - string[]
    - `decodeLogs` boolean: Resolve event signatures and decode inputs.
    - `descOrder` boolean: Sort newest first when `true`.
    - `pageSize` integer: Entries per page. Default `1000`, max `10000`.
    - `pageToken` string: Opaque page token from a prior response's `nextPageToken`.

## Response `200`

Success. JSON-RPC `result` envelope contains the `logs` array and pagination cursor. 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
    - `nextPageToken` string
    - `logs` object[], nullable, required: Indexed log entries.
      - `address` string, required
      - `blockHash` string, required
      - `blockNumber` string, required: Hex-encoded block number.
      - `blockchain` 'arbitrum' | 'avalanche' | 'base' | 'bsc' | 'eth' | 'fantom' | 'flare' | 'gnosis' | 'linea' | 'optimism' | 'polygon' | 'scroll' | 'somnia_mainnet' | 'taiko' | 'telos' | 'xlayer' | 'avalanche_fuji' | 'base_sepolia' | 'eth_sepolia' | 'optimism_sepolia' | 'polygon_amoy', required
      - `data` string, required: Non-indexed log arguments (hex).
      - `logIndex` string, required
      - `removed` boolean, required: `true` if removed by a reorg.
      - `topics` string[], nullable, required: Up to 4 indexed topic hashes.
      - `transactionHash` string, required
      - `transactionIndex` string, required
      - `event` object: Decoded event metadata (only when `decodeLogs: true`).
        - `anonymous` boolean
        - `id` string
        - `name` string
        - `signature` string
        - `string` string
        - `verified` boolean
        - `inputs` object[], nullable
          - `indexed` boolean
          - `name` string
          - `size` integer
          - `type` string
          - `valueDecoded` string

## 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)
