Python Forum
Add Tor proxy to blockchain API call
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add Tor proxy to blockchain API call
#1
He everyone.
I am trying to call blockchain address detail endpoint several times. After a while my IP is blocked, and the response of my call is 429 Too Many request.
I would like to add Tor proxy redirection to my method, in order to get a new IP address once at 5-10 calls. Tor proxy is generating a new IP every 5 seconds. Usually I am getting banned after 20 seconds if I call the resource in 5 threads (each thread same IP).
Could you please provide a implementation at my python method with call redirection through TOR?
I need this in order to make unlimited calls to blockchain address detail endpoint. Endpoint call Example: Get on https://blockchain.info/multiaddr?active={addr}&n=1. Where {addr} is substituted with a btc public address, Example: https://blockchain.info/multiaddractive=...fgX2pa&n=1
Note:
the endpoint will be called from multiple threads or multiprocessing. Every thread should have it unique IP. I need a logic that will get each thread a valid Unique IP then make the call.
Below is my python method:

def getBalance(addr):
    try:
        time.sleep(1)
        response = requests.get(
            f'https://blockchain.info/multiaddr?active={addr}&n=1')

        return (
            response.json()['wallet']
        )
    except:
        print("your Ip got banned. Turn your VPN on")
        time.sleep(5)
        getBalance(addr)
        pass
getBalance() Method is called by each thread.
Yoriz write Sep-24-2021, 05:37 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cryptocurrency Blockchain Error johnnypy76 2 3,795 Nov-10-2019, 12:03 AM
Last Post: johnnypy76

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020