I am unable to find the correct API call format to download the input data field from the event log of each transaction - is there a way to use API key to download this information?

I am referring to downloading the data of this input data field: enter image description here


You can use Etherscan Event Log API, which fetches up to 1000 events for a given range of blocks (if there are more than 1000 events in the given range, then only the first 1000 events are fetched).

For each event, it returns the following object:

    address         : ...,
    topics          : [ ... ],
    data            : ...,
    blockNumber     : ...,
    timeStamp       : ...,
    gasPrice        : ...,
    gasUsed         : ...,
    logIndex        : ...,
    transactionHash : ...,
    transactionIndex: ...

The value of the inputData field can be found within the topics and data fields.

More precisely, the topics field is an array which consists of the event signature hash (first item) and each one of the event's indexed parameter values (second item onward), while the data field is a string which consists of the concatenation of the event's unindexed parameter values.

Here is a coding example:

const request = require("request");

const CONTRACT_ADDRESS  = "...";
const ETHERSCAN_API_KEY = "...";
const ETHERSCAN_API_URL = "http://api.etherscan.io/api?module=logs&action=getLogs&address=" + CONTRACT_ADDRESS + "&apikey=" + ETHERSCAN_API_KEY;

const MAX_TIMEOUT = 10000;
const MAX_RESULTS = 1000;

function scan(fromBlock, toBlock) {
    request(`${ETHERSCAN_API_URL}&fromBlock=${fromBlock}&toBlock=${toBlock}`, {timeout: MAX_TIMEOUT}, function(error, response, body) {
        const parsed = parse(body);
        if (parsed.result) {
            if (parsed.result.length < MAX_RESULTS) {
                for (const event of parsed.result)
                    console.log(event.topics.slice(1), event.data);
            else {
                console.log("warning: too many events");
                for (const event of parsed.result)
                    console.log(event.topics.slice(1), event.data);
        else {
            console.log("error:", error);

function parse(str) {
    try {
        return JSON.parse(str);
    catch (error) {
        return {};

  • Thanks for this - however, the above still cannot download the input data. For example see this specific transaction: etherscan.io/tx/… I want to download the Input data field inside the overview, the Etherscan Event Log does not contain this field it seems
    – cg202220
    Feb 23 '20 at 23:24
  • @cg202220: What do you mean "see this transaction"? Your question says "from the event log". Was there an event during this transaction? Otherwise, you should change your question. My answer was under the assumption that you are looking for event data. Feb 24 '20 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.