import requests
# Define the base URL for the Blockchain.com API
base_url = "https://api.blockchain.com/v3"
# Transaction ID you want to retrieve
transaction_id = "your_transaction_id_here"
# Create the API endpoint URL for fetching transaction data
endpoint = f"{base_url}/rawtx/{transaction_id}"
try:
# Make the API request to fetch transaction data
response = requests.get(endpoint)
# Check if the request was successful (status code 200)
if response.status_code == 200:
transaction_data = response.json()
# Print or process the transaction data as needed
print("Transaction Data:")
print(transaction_data)
else:
print(f"Error: Unable to fetch transaction data. Status code: {response.status_code}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
_____________________________________________
Note ;
1 Replace "your_transaction_id_here"
with the actual transaction ID you want to retrieve.
2 You will need the "requests" library in Python to make HTTP requests. You can install it using " pip install requests ".