I want to connect to the etherscan Ropsten test-net with python:

URL = 'https://api-ropsten.etherscan.io/api?module=contract&action=getsourcecode&address=0x1c7f98370206b4d44bfbb011c65bc582fcdae4fe&apikey='+ API_key
s = requests.Session()
response = s.get(URL)

The response code is always Forbidden 403. I tested with curl the same url and it works. I tried to use py-etherscan-api, but there are no examples how to connect to Ropsten.

  • Hi there. Here's the Ropsten connection code from py-etherscan-api, which definitely worked last time I ran the associated test code -> github.com/corpetty/py-etherscan-api/blob/… – Richard Horrocks Dec 25 '19 at 12:47
  • @RichardHorrocks Same problem connecting to Ropsten Testing with: from etherscan.client import Client c = Client( address = "0x40ee8545373109ebf5d6dfac420ebbf96d09bf76", api_key="3EUHGMN7XGMM5YKJ6T98SV7H652CFD1PDB") c.PREFIX = "api-ropsten.etherscan.io/api?" c.build_url() c.connect() – Daniel Dias Dec 25 '19 at 13:52
  • How did you pass this problem? – Sergey Kargapoltsev Aug 6 at 15:38
  • Using a request header from another source REQUESTS_HEADERS = { "User-Agent": "github.com/AndreMiras/pyetheroll", } response = requests.get(URL, headers=REQUESTS_HEADERS) – Daniel Dias Oct 1 at 13:27

Your Answer

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

Browse other questions tagged or ask your own question.