xuhcc / beancount-ethereum-importer

Ethereum transaction importer for Beancount
GNU General Public License v3.0
11 stars 5 forks source link

"Max rate limit reached" #1

Closed stin7 closed 3 years ago

stin7 commented 3 years ago

Thanks for publishing this.

I get an error about exceeding the rate limit:

❯ python importers/eth/beancount_ethereum/downloader.py --config=importers/eth/config.json --output-dir=downloads
Traceback (most recent call last):
  File "importers/eth/beancount_ethereum/downloader.py", line 150, in <module>
    main(config, output_dir)
  File "importers/eth/beancount_ethereum/downloader.py", line 132, in main
    transactions += get_erc20_transfers(api_url, api_key, address)
  File "importers/eth/beancount_ethereum/downloader.py", line 106, in get_erc20_transfers
    for item in make_api_request(api_url, api_key, address, 'tokentx'):
  File "importers/eth/beancount_ethereum/downloader.py", line 44, in make_api_request
    raise RuntimeError(response)
RuntimeError: b'{"status":"0","message":"NOTOK","result":"Max rate limit reached"}'

On the etherscan page, it looks like the limit is 5 calls/s

Perhaps we can add a backoff, or hardcode the rate limit. For now I will try a hack with sleep...

stin7 commented 3 years ago

(confirmed that adding sleep(0.1) as the first line in make_api_request() works, if hacky)

xuhcc commented 3 years ago

{"status":"0","message":"NOTOK","result":"Max rate limit reached"}

I'm wondering what 'NOTOK' means. Are you using it without an API token?

stin7 commented 3 years ago

I did use a token - and when I added the sleep call it worked fine. So NOTOK seems misleading on their end.

xuhcc commented 3 years ago

Added a configurable delay between the requests: block_explorer_api_request_delay:

https://github.com/xuhcc/beancount-ethereum-importer/blob/master/config.json.example