APIs used:
  • Get paginated transactions for address (v3)  
  • Get earliest transactions for address (v3)  
  • Get transaction summary for address  
  • Get a transaction  

Introduction

At Covalent, we're committed to providing powerful blockchain data solutions, and our suite of APIs is designed to simplify the process of interacting with blockchain data. This guide focuses on how to utilize our APIs to fetch detailed Ethereum transaction histories efficiently, a vital task for developers working in the blockchain space.

info
These endpoints are part of the Covalent Unified API, which offers the same requests on over 200 supported blockchains. Follow this guide to get transaction history on Polygon, Fantom, Avalanche and more by simply changing the chain name parameter in your requests.

Understanding Ethereum Transactions

Ethereum transactions are the lifeblood of the Ethereum network, enabling the transfer of value and information between parties. Tracking these transactions is crucial for a wide range of applications, from wallet services to analytical tools. This guide will help you understand how to leverage the Covalent's API to access this vital data.

Overview of Covalent's Historical Transaction APIs

Covalent offers several APIs that make accessing Ethereum transaction data straightforward and efficient:

Get paginated transactions for address (v3)

GET/v1/{chainName}/address/{walletAddress}/transactions_v3/page/{page}/

Commonly used to fetch the transactions involving an address including the decoded log events in a paginated fashion.

Get transaction summary for address

GET/v1/{chainName}/address/{walletAddress}/transactions_summary/

Commonly used to fetch the earliest and latest transactions, and the transaction count for a wallet. Calculate the age of the wallet and the time it has been idle and quickly gain insights into their engagement with web3.

Get earliest transactions for address (v3)

GET/v1/{chainName}/bulk/transactions/{walletAddress}/

Commonly used to fetch and render the earliest transactions involving an address. Frequently seen in wallet applications.

Get a transaction

GET/v1/{chainName}/transaction_v2/{txHash}/

Commonly used to fetch and render a single transaction including its decoded log events. Additionally return semantically decoded information for DEX trades, lending and NFT sales.

Using Covalent's API to Get Paginated Transactions for an Address

The endpoint is a robust tool for developers who need to manage large volumes of transaction data. Here's how to use it:

shell
curl -X GET https://api.covalenthq.com/v1/eth-mainnet/address/{walletAddress}/transactions_v3/page/{page}/? \
    -H 'Content-Type: application/json' \
    -u cqt_rQYWtk8wJ9hx44xXJCb4P9D63GX7: \
     # The colon prevents curl from asking for a password

This endpoint is invaluable for applications requiring a chronological view of transaction history, allowing for efficient data retrieval and user-friendly display. It includes decoded event logs to provide context on the transaction action, as well as formatted fiat quotes, protocol details and additional information.

Fetching Earliest Transactions for an Address

Finding an address's initial interactions on the blockchain is necessary both for the user and the developer needing to know where to paginate results from. The endpoint serves this need effectively:

shell
curl -X GET https://api.covalenthq.com/v1/eth-mainnet/bulk/transactions/{walletAddress}/? \
    -H 'Content-Type: application/json' \
    -u cqt_rQYWtk8wJ9hx44xXJCb4P9D63GX7: \
     # The colon prevents curl from asking for a password

This API is particularly useful for wallet applications and historical analysis.

Understanding Transaction Summary for an Address

The endpoint offers a quick way to gauge a wallet's activity, providing data on the earliest and latest transactions and the transaction count.

Installation:

Bash
npm install @covalenthq/client-sdk

Request:

TypeScript
import { CovalentClient } from "@covalenthq/client-sdk";

const ApiServices = async () => {
    const client = new CovalentClient("cqt_rQYWtk8wJ9hx44xXJCb4P9D63GX7");
    const resp = await client.TransactionService.getTransactionSummary("eth-mainnet");
    console.log(resp.data);
}

It's an excellent tool for applications that need to assess user engagement or wallet activity at a glance.

Retrieving Detailed Information on a Specific Transaction

For in-depth transaction analysis, the endpoint is invaluable. It provides detailed data, including decoded log events:

Installation:

Bash
npm install @covalenthq/client-sdk

Request:

TypeScript
import { CovalentClient } from "@covalenthq/client-sdk";

const ApiServices = async () => {
    const client = new CovalentClient("cqt_rQYWtk8wJ9hx44xXJCb4P9D63GX7");
    const resp = await client.TransactionService.getTransaction("eth-mainnet");
    console.log(resp.data);
}

This endpoint is essential for applications that need to present a complete view of a transaction, including DEX trades, lending, and NFT sales.

Different Ways to Use the Covalent API

The Covalent API can be utilized via direct HTTP requests or through the Typescript and Python SDKs. In this section, we'll focus on the flexibility and ease of use provided by these different methods, particularly highlighting the Transactions endpoint in the Typescript SDK.

1. Using the Covalent API with HTTP Requests

Developers can directly interact with the Covalent API using HTTP requests. This approach is language-agnostic and can be implemented in any environment that allows HTTP requests. It's a straightforward method where developers construct and send requests to the Covalent API endpoints and parse the responses.

  • Flexibility: HTTP requests offer maximum flexibility, allowing developers to integrate the API into various software architectures and platforms.

  • Customization: This method permits extensive customization of requests, including headers, query parameters, and request bodies.

  • Broad Compatibility: It's universally compatible with all programming environments that support HTTP.

2. Using the Covalent API with the Typescript SDK

For developers working in a TypeScript or JavaScript environment, the Covalent Typescript SDK offers a more streamlined and convenient way to interact with the API.

  • Ease of Use: The SDK simplifies the process of making requests and handling responses. It abstracts the complexities of direct HTTP communication.

  • Enhanced Functions: The SDK includes enhanced functions like next() and prev() in certain methods (e.g., getAllTransactionsForAddressByPage(), getTransactionsForAddressV3(), and getTimeBucketTransactionsForAddress()). These functions facilitate easier navigation through paginated data.

  • Code Example: Here's a quick example of how to use the Typescript SDK:

TypeScript
import { CovalentClient } from "@covalenthq/client-sdk";

const client = new CovalentClient("YOUR_API_KEY"); // Replace with your Covalent API key.
const resp = await client.TransactionService.getAllTransactionsForAddressByPage("eth-mainnet", "WALLET_ADDRESS");
// assuming resp.data.current_page is 10
if (resp.data !== null) {
    const prevPage = await resp.data.prev(); // will retrieve page 9
    console.log(prevPage.data);
}

In this example, fetching transactions for an Ethereum wallet address is simplified, and navigating through pages is made more intuitive with the prev() method.

3. Using the Covalent API with the Python SDK

The Python SDK is another option for developers, especially those who are working within a Python-based environment.

  • Pythonic Interface: The SDK provides a Python-friendly interface to interact with the Covalent API, making it a natural choice for Python developers.

  • Integration with Python Tools: It can be easily integrated with popular Python tools and frameworks, enhancing its utility in data analysis, web development, and scripting.

  • Installation:

Python
pip3 install covalent-api-sdk

Practical Use Cases and Applications

The versatility of Covalent's APIs makes them suitable for a wide range of applications:

  • Wallet Services: For displaying transaction histories to users.

  • Analytical Tools: To analyze trends and wallet activities.

  • Auditing Purposes: Ensuring transparency and compliance in transactions.

Best Practices and Tips

When integrating these APIs:

  • Always paginate results to manage data load efficiently.

  • Cache frequently accessed data to improve performance.

  • Handle exceptions and errors gracefully to enhance user experience.

Conclusion

Covalent's Historical Transaction APIs are a powerful toolkit for developers looking to get a user's Ethereum transaction history or any other on-chain transaction data. By following this guide, you can effectively integrate these APIs into your applications and build better applications, easier.

FAQs

  1. How can I manage large volumes of transaction data?

    • Use the paginated transactions endpoint to efficiently handle data.

  2. Can I track the first-ever transaction of an address?

    • Yes, with the endpoint.

For further inquiries or support, feel free to contact our developer support team or visit our documentation for more details.