0% found this document useful (0 votes)
22 views2 pages

Alchemy Asset Transfers in Python/CURL

The document provides a CURL command and a Python script for making a JSON-RPC request to the Alchemy API to retrieve asset transfers. The request specifies parameters such as the block range, target address, and categories of transfers. The Python script includes error handling and prints the response from the API call.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Alchemy Asset Transfers in Python/CURL

The document provides a CURL command and a Python script for making a JSON-RPC request to the Alchemy API to retrieve asset transfers. The request specifies parameters such as the block range, target address, and categories of transfers. The Python script includes error handling and prints the response from the API call.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

This command is in CURL

{
"id": 1,
"jsonrpc": "2.0",
"method": "alchemy_getAssetTransfers",
"params": [
{
"fromBlock": "0x0",
"toBlock": "latest",
"toAddress": "0x4761d7306ffd97b64a72d1007189b5ca799c6eea",
"withMetadata": false,
"excludeZeroValue": true,
"maxCount": "0x3e8",
"category": [
"external"
]
This command is in Python

import requests

# Alchemy API endpoint and API key


url = "[Link]

# Headers
headers = {
"accept": "application/json",
"content-type": "application/json"
}

# Request payload
payload = {
"id": 1,
"jsonrpc": "2.0",
"method": "alchemy_getAssetTransfers",
"params": [
{
"fromBlock": "0x0",
"toBlock": "latest",
"toAddress": "0x4761d7306ffd97b64a72d1007189b5ca799c6eea",
"withMetadata": False,
"excludeZeroValue": True,
"maxCount": "0x3e8",
"category": [
"external"
]
}
]
}

# Make the POST request


response = [Link](url, headers=headers, json=payload)

# Print the response


if response.status_code == 200:
print([Link]())
else:
print(f"Error: {response.status_code}, {[Link]}")

You might also like