Skip to main content

How to Fetch Ethereum Transaction History with Tokenview Blockchain API

tokenviewAbout 2 min

How to Fetch Ethereum Transaction History with Tokenview Blockchain API

Ethereum's blockchain is a smart ecosystem, with transactions occurring constantly as users interact with decentralized applications (dApps), swap tokens, and execute smart contracts. For developers building applications on Ethereum, accessing transaction history is vital for various purposes, from user experience enhancements to auditing and analytics. In this guide, we'll explore how developers can fetch Ethereum transaction history using the Tokenview Blockchain API.

Understanding the Tokenview Blockchain API:
Tokenview offers a comprehensive suite of blockchain data servicesopen in new window, including APIs for various blockchains like Bitcoin and Ethereum. Their Blockchain API provides developers with easy access to essential blockchain data, including transaction history, blocks, addresses, and more.

Fetching Ethereum Transaction History:
To fetch Ethereum transaction history using the Tokenview Blockchain API, follow these steps:

  1. Get API Access: First, sign upopen in new window for a Tokenview account and obtain API access credentials. Tokenview offers both free and paid plans, depending on your usage needs.

  2. Construct the API Request: To fetch transaction history for a specific Ethereum address, construct an API request using the appropriate endpoint. For example, the endpointopen in new window /vipapi/eth/{address} retrieves the transaction history for a given Ethereum address.

  3. Specify Parameters: Include any additional parameters required by the API endpoint. For transaction history, parameters may include the Ethereum address, token address, pagination options (e.g., page number, page size).

curl --location https://services.tokenview.io/vipapi/eth/address/tokentrans/0x6bccd9664ac9ca942d1ce7ae92d22cb98c63db7c/0xdac17f958d2ee523a2206206994597c13d831ec7/1/50?apikey={apikey}
  1. Send the Request: Use your preferred programming language or tool (e.g., cURL, Python requests library) to send the API request to Tokenview's servers. Make sure to include your API access credentials in the request headers for authentication.

  2. Handle the Response: Once the API request is sent, Tokenview's servers will process the request and return the Ethereum transaction history in the response body. Parse the JSON-formatted responseopen in new window to extract relevant information such as transaction hashes, timestamps, sender/receiver addresses, and transaction amounts.

{
    "code": 1,
    "msg": "成功",
    "data": [
        {
            "index": 126,
            "block_no": 9285925,
            "token": "0xdac17f958d2ee523a2206206994597c13d831ec7",
            "tokenAddr": "0xdac17f958d2ee523a2206206994597c13d831ec7",
            "tokenSymbol": "USDT",
            "tokenDecimals": "6",
            "time": 1579094101,
            "txid": "0x3ae0ba32fd729c8902c3cf3b17bcca211527eaa2c0780c42a8e392ac401ba137",
            "tokenInfo": {
                "h": "0xdac17f958d2ee523a2206206994597c13d831ec7",
                "f": "Tether USD",
                "s": "USDT",
                "d": "6"
            },
            "confirmations": 6880062,
            "from": "0x6bccd9664ac9ca942d1ce7ae92d22cb98c63db7c",
            "to": "0xcf3618d4680817af786a1d93465a19ab4225e69e",
            "value": "219772901"
        }
    ]
}
  1. Integrate into Your Application: Finally, integrate the fetched transaction history data into your application as needed. You can display transaction history to users, perform analysis, or use it for backend processes.

Example Code (Python using requests library):

import requests

# Tokenview API endpoint
url = 'https://services.tokenview.io/vipapi/eth/address/tokentrans/{address}/{token_address}/{page_num}/{page_size}?apikey={apikey}'

# API access credentials
api_key = 'your_api_key'

# Ethereum address to fetch transaction history for
address = '0xYourEthereumAddress'

# Token address to fetch on address
token_address = '0xTokenAddress'

# Construct API request parameters
url = url.format(address = address, token_address = token_address, page_num = 1, page_size = 10, apikey = api_key)

# Send API request
response = requests.get(url)

# Handle response
if response.status_code == 200:
    data = response.json()
    transactions = data['data']['list']
    for tx in transactions:
        print(tx)  # Example: Print transaction details
else:
    print('Error:', response.status_code)

Fetching Ethereum transaction history using the Tokenview Blockchain APIopen in new window is straightforward and provides developers with valuable insights into blockchain activity. By leveraging this API, developers can enhance their Ethereum applications with features that rely on transaction history data, improving user experience and enabling deeper analytics and auditing capabilities. Whether you're building a wallet app, a decentralized exchange, or a blockchain explorer, access to transaction history is essential for understanding and interacting with the Ethereum blockchain effectively.

About Tokenview Blockchain APIs & Data Service Platform:

Tokenview blockchain APIs & data service platform contained 120+ blockchains has powerful endpoints that simplify complex blockchain data into single API calls. Code for all supported blockchains using unified API calls. From here to easily get transaction, address, gas, contract, token, NFT, logs and any information from chain. And Yes you can also send tx to chain. One-click configuration with APIKey helps developers to Use, to Create, to Build.
Last update: