---
updatedAt: 2025-02-19T23:29:23.000Z
agentTools:
  projectIndex: https://api-docs.ankr.com/llms.txt
---

# ankr_getLogs

Retrieves historical data for the specified range of blocks.

# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Ankr Advanced API",
    "version": ""
  },
  "servers": [
    {
      "url": "https://rpc.ankr.com/multichain/79258ce7f7ee046decc3b5292a24eb4bf7c910d7e39b691384c7ce0cfb839a01"
    }
  ],
  "tags": [
    {
      "name": "Query API"
    }
  ],
  "paths": {
    "/?ankr_getLogs": {
      "post": {
        "tags": [
          "Query API"
        ],
        "summary": "ankr_getLogs",
        "description": "Retrieves historical data for the specified range of blocks.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "id",
                  "jsonrpc",
                  "method",
                  "params"
                ],
                "type": "object",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "jsonrpc": {
                    "enum": [
                      "2.0"
                    ],
                    "type": "string"
                  },
                  "method": {
                    "enum": [
                      "ankr_getLogs"
                    ],
                    "type": "string"
                  },
                  "params": {
                    "type": "object",
                    "properties": {
                      "address": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "Сontract address or a list of addresses from which logs should originate."
                      },
                      "blockchain": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "Name of the blockchain or list of blockchain names. Single: eth. Multiple: [arbitrum, avalanche, base, bsc, eth, fantom, flare, gnosis, linea, optimism, polygon, polygon_zkevm, rollux, scroll, syscoin, avalanche_fuji, eth_goerli, optimism_testnet, polygon_mumbai]. All chains: empty value.",
                        "nullable": true
                      },
                      "decodeLogs": {
                        "type": "boolean",
                        "description": "Decode logs (true) or not (false)."
                      },
                      "descOrder": {
                        "type": "boolean",
                        "description": "Sorting order. Descending (true) or ascending (false).",
                        "default": true
                      },
                      "fromBlock": {
                        "minimum": 0,
                        "type": "integer",
                        "description": "Number of the first block in a range. Integer or string (number, hex value, 'earliest' or 'latest')."
                      },
                      "fromTimestamp": {
                        "minimum": 0,
                        "type": "integer",
                        "description": "Beginning of a time period. UNIX timestamp."
                      },
                      "pageSize": {
                        "type": "integer",
                        "description": "Number of entries per page. int32.",
                        "default": 1000
                      },
                      "pageToken": {
                        "type": "string",
                        "description": "Current page token for pagination."
                      },
                      "syncCheck": {
                        "type": "boolean",
                        "description": "If false, the data is returned regardless of indexer health, if true, the data is returned only when the indexer health check is positive."
                      },
                      "toBlock": {
                        "description": "Number of the last block in a range. Integer or string (number, hex value, 'earliest' or 'latest')."
                      },
                      "toTimestamp": {
                        "description": "End of a time period. UNIX timestamp."
                      },
                      "topics": {
                        "type": "array",
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "array",
                            "items": {
                              "minimum": 0,
                              "type": "integer"
                            }
                          }
                        },
                        "description": "Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with 'or' options."
                      }
                    },
                    "description": "Click on PARAM OBJECT and edit body params before clicking Try it! And set request id!"
                  }
                }
              },
              "examples": {
                "From earliest to latest": {
                  "value": {
                    "id": 1,
                    "jsonrpc": "2.0",
                    "method": "ankr_getLogs",
                    "params": {
                      "address": [
                        "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
                      ],
                      "blockchain": "eth",
                      "fromBlock": "earliest",
                      "pageSize": 1,
                      "toBlock": "latest",
                      "topics": [
                        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                      ]
                    }
                  }
                },
                "Pagination": {
                  "value": {
                    "id": 1,
                    "jsonrpc": "2.0",
                    "method": "ankr_getLogs",
                    "params": {
                      "address": [
                        "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
                      ],
                      "blockchain": "eth",
                      "fromBlock": "earliest",
                      "pageSize": 10,
                      "pageToken": "BTpvRzNUs3GnYWodAVSQEL6eEPL5Kd1epyUBTym9y3paNH4bZ9CQreQFz1oGPZBWBoJHYT7aH1PDwRKV9s",
                      "toBlock": "latest",
                      "topics": [
                        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                      ]
                    }
                  }
                },
                "With event decoding": {
                  "value": {
                    "id": 1,
                    "jsonrpc": "2.0",
                    "method": "ankr_getLogs",
                    "params": {
                      "address": [
                        "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
                      ],
                      "blockchain": "eth",
                      "decodeLogs": true,
                      "fromBlock": "0xdaf6b1",
                      "toBlock": 14350010,
                      "topics": [
                        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                        "0x000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff",
                        "0x0000000000000000000000003dd49f67e9d5bc4c5e6634b3f70bfd9dc1b6bd74"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "required": [
                    "id",
                    "jsonrpc",
                    "result"
                  ],
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "jsonrpc": {
                      "enum": [
                        "2.0"
                      ],
                      "type": "string"
                    },
                    "result": {
                      "required": [
                        "logs"
                      ],
                      "type": "object",
                      "properties": {
                        "logs": {
                          "type": "array",
                          "items": {
                            "required": [
                              "blockchain",
                              "address",
                              "topics",
                              "data",
                              "blockNumber",
                              "transactionHash",
                              "transactionIndex",
                              "blockHash",
                              "logIndex",
                              "removed"
                            ],
                            "type": "object",
                            "properties": {
                              "address": {
                                "type": "string",
                                "description": "Address from which the log originated."
                              },
                              "blockHash": {
                                "type": "string",
                                "description": "Hash of the block where the log was in. null when it's a pending log."
                              },
                              "blockNumber": {
                                "type": "string",
                                "description": "Block number where the log was in. null when it's a pending log."
                              },
                              "blockchain": {
                                "enum": [
                                  "arbitrum",
                                  "avalanche",
                                  "avalanche_fuji",
                                  "base",
                                  "bsc",
                                  "eth",
                                  "eth_goerli",
                                  "fantom",
                                  "flare",
                                  "gnosis",
                                  "linea",
                                  "optimism",
                                  "optimism_testnet",
                                  "polygon",
                                  "polygon_mumbai",
                                  "polygon_zkevm",
                                  "rollux",
                                  "scroll",
                                  "syscoin"
                                ],
                                "type": "string",
                                "description": "Name of the blockchain."
                              },
                              "data": {
                                "type": "string",
                                "description": "One or more 32B non-indexed arguments of the log."
                              },
                              "event": {
                                "type": "object",
                                "properties": {
                                  "anonymous": {
                                    "type": "boolean",
                                    "description": "Anonymous event (true) or not (false)."
                                  },
                                  "id": {
                                    "type": "string",
                                    "description": "Hash of the event signature."
                                  },
                                  "inputs": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "indexed": {
                                          "type": "boolean",
                                          "description": "Indexed event input (true) or non-indexed (false)."
                                        },
                                        "name": {
                                          "type": "string",
                                          "description": "Name of the input."
                                        },
                                        "size": {
                                          "type": "integer",
                                          "description": "Size of the event input."
                                        },
                                        "type": {
                                          "type": "string",
                                          "description": "Type of the input."
                                        },
                                        "valueDecoded": {
                                          "type": "string",
                                          "description": "Decoded value of the event input (unmarshalled)."
                                        }
                                      }
                                    },
                                    "description": "Inputs of the event.",
                                    "nullable": true
                                  },
                                  "name": {
                                    "type": "string",
                                    "description": "Name of the event."
                                  },
                                  "signature": {
                                    "type": "string",
                                    "description": "Signature of the event."
                                  },
                                  "string": {
                                    "type": "string",
                                    "description": "String containing signature of the event."
                                  },
                                  "verified": {
                                    "type": "boolean",
                                    "description": "Status of the contract. Verified (true) or not verified (false)."
                                  }
                                },
                                "description": "Metadata of the log."
                              },
                              "logIndex": {
                                "type": "string",
                                "description": "Integer of the log index position in the block. null when it's a pending log."
                              },
                              "removed": {
                                "type": "boolean",
                                "description": "Status of the log. True when the log was removed due to a chain reorganization, and false if it's a valid log."
                              },
                              "topics": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "description": "Array of zero to four 32B DATA of indexed log arguments. In Solidity, the first topic is the hash of the signature of the event (e.g. Deposit(address, bytes32, uint256)), except you declare the event with the anonymous specifier.",
                                "nullable": true
                              },
                              "transactionHash": {
                                "type": "string",
                                "description": "Hash of the transactions the log was created from. null when its a pending log."
                              },
                              "transactionIndex": {
                                "type": "string",
                                "description": "Integer of the transaction's index position that the log was created from. null when it's a pending log."
                              }
                            }
                          },
                          "description": "Logs on the queried range of blocks.",
                          "nullable": true
                        },
                        "nextPageToken": {
                          "type": "string",
                          "description": "Next page token for pagination."
                        },
                        "syncStatus": {
                          "type": "object",
                          "properties": {
                            "lag": {
                              "type": "string",
                              "description": "Timestamp difference between the latest block on the blockchain and on the indexer."
                            },
                            "status": {
                              "type": "string",
                              "description": "Sync status of the indexer: synced or outOfSync."
                            },
                            "timestamp": {
                              "minimum": 0,
                              "type": "integer",
                              "description": "Timestamp of latest block the indexer is at."
                            }
                          },
                          "description": "Information on the status of the queried indexer.",
                          "nullable": true
                        }
                      },
                      "description": "Result of the query."
                    }
                  }
                },
                "examples": {
                  "With event decoding": {
                    "value": {
                      "id": 1,
                      "jsonrpc": "2.0",
                      "result": {
                        "logs": [
                          {
                            "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                            "blockHash": "0x76fe73c4d2a66bb0cba343482521c8cd44f0ef824e97493f3c4f3e5140422ea5",
                            "blockNumber": "0xdaf6b4",
                            "blockchain": "eth",
                            "data": "0x00000000000000000000000000000000000000000000000000787f498b5b22b7",
                            "event": {
                              "anonymous": false,
                              "id": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                              "inputs": [
                                {
                                  "indexed": true,
                                  "name": "_from",
                                  "size": 20,
                                  "type": "address",
                                  "valueDecoded": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
                                },
                                {
                                  "indexed": true,
                                  "name": "_to",
                                  "size": 20,
                                  "type": "address",
                                  "valueDecoded": "0x3dd49f67E9d5Bc4C5E6634b3F70BfD9dc1b6BD74"
                                },
                                {
                                  "indexed": false,
                                  "name": "_value",
                                  "size": 256,
                                  "type": "uint256",
                                  "valueDecoded": "33916951052624567"
                                }
                              ],
                              "name": "Transfer",
                              "signature": "Transfer(address,address,uint256)",
                              "string": "event Transfer(address indexed _from, address indexed _to, uint256 _value)",
                              "verified": false
                            },
                            "logIndex": "0x49",
                            "removed": false,
                            "topics": [
                              "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                              "0x000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff",
                              "0x0000000000000000000000003dd49f67e9d5bc4c5e6634b3f70bfd9dc1b6bd74"
                            ],
                            "transactionHash": "0x6f11297b0964a0fb0630e6667093a6c9cee4b383495c94e99becc6b88aed8f14",
                            "transactionIndex": "0x3f"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-readme": {
          "code-samples": [
            {
              "code": "import { AnkrProvider } from '@ankr.com/ankr.js';\n\nconst provider = new AnkrProvider();\nconst logs = async () => {\n  return await provider.getLogs({\n    blockchain: 'eth',\n    fromBlock: 1181739,\n    toBlock: 1181749,\n    topics: [\n      [],\n      ['0x000000000000000000000000feb92d30bf01ff9a1901666c5573532bfa07eeec'],\n    ],\n    address: '0x3589d05a1ec4af9f65b0e5554e645707775ee43c',\n    decodeLogs: false,\n  });\n};logs().then((reply) => {\n  console.log(reply)\n})",
              "install": "npm install @ankr.com/ankr.js",
              "language": "node",
              "name": "Request via Ankr.js SDK"
            }
          ]
        }
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```