I'm sure this question was asked before, but I did not find any result that helped my problem.
How can I get the transactions (in and out) for a given account? I use nodejs and web3?
With this line I get the number of sent transactions:
So at least web3 should know something about the account activity.
Is there an easy way to get the transactions of my accounts? Or did I miss something about it? Do I have to crawl the entire blockchain, block by block, to get my transactions?
Simple transactions are not indexed. So you either need to iterate over all the blocks, use some kind of an off-chain index (e.g. etherscan.io), or build one up yourself and use it.
For example, you can use this heuristic approach without having to process the entire chain
How does it work?
Using the available information about the current state (number of "from" transactions and the current balance), it goes back in time until at least so many "from" transactions have been found, and then continues going back until the balance reaches
The inherent limitation is that 0-value transactions before the account was funded will not be found.
Contract events on the other hand, are indexed. So if you're developing a smart contract, you can make use of that.
Using web3 1.0.0 API:
Or via JSON RPC eth_getLogs.