SDKs overview

Covalent offers Software Development Kits (SDKs) to facilitate interaction with its Unified API, which aggregates blockchain data from multiple networks. These SDKs simplify the process of fetching data such as token balances, NFT metadata, transaction histories, and protocol-specific data without requiring developers to manage individual blockchain nodes or complex data indexing infrastructure. The primary goal of these SDKs is to provide a consistent interface for developers building decentralized applications (dApps), analytics platforms, and other blockchain-aware services.

The SDKs are designed to abstract the underlying HTTP requests and JSON parsing, allowing developers to focus on application logic rather than data retrieval mechanics. Covalent's approach to data indexing aims to provide a comprehensive and historical view of blockchain activity, addressing challenges associated with the ephemeral nature and distributed storage of blockchain data. This enables more efficient development of applications that require extensive data queries across various blockchain ecosystems optimizing content efficiency in blockchain applications.

Official SDKs by language

Covalent maintains official SDKs for popular programming languages, providing idiomatic interfaces for interacting with the Covalent API. These SDKs are developed and supported by the Covalent team, ensuring compatibility with the latest API versions and features. They typically include methods corresponding to the various endpoints available in the Covalent Unified API, covering data types such as balances, transactions, NFTs, and log events. The official Covalent documentation provides up-to-date guidance on using these libraries.

Language Package Name Install Command Maturity
JavaScript @covalent/client npm install @covalent/client or yarn add @covalent/client Stable
Python covalent-api pip install covalent-api Stable
Go github.com/covalent-xyz/covalent-go go get github.com/covalent-xyz/covalent-go Stable

Each SDK is designed to align with the conventions and best practices of its respective language. For example, the JavaScript SDK leverages asynchronous programming patterns common in web development, while the Python SDK integrates well with data science workflows. The Go SDK is built for performance and concurrency, suitable for backend services requiring high throughput. Developers should consult the Covalent API reference documentation for detailed endpoint specifications and parameter requirements when using these SDKs.

Installation

Installation of Covalent SDKs typically follows standard package management practices for each programming language. An API key is required for authentication with the Covalent API, which can be obtained by signing up on the Covalent pricing page for a free tier or paid plan.

JavaScript SDK

To install the JavaScript SDK, use npm or Yarn:

npm install @covalent/client
# or
yarn add @covalent/client

This package provides a client for interacting with the Covalent API in both Node.js and browser environments. It is designed to be compatible with modern JavaScript module systems.

Python SDK

For Python, use pip:

pip install covalent-api

The Python SDK offers a straightforward interface to Covalent's data, making it suitable for scripting, data analysis, and integrating into Python-based backend services. For example, developers building on Salesforce Platform might use Python for backend integrations.

Go SDK

Install the Go SDK using go get:

go get github.com/covalent-xyz/covalent-go

The Go SDK is structured to provide type-safe access to Covalent's data models and API endpoints, which is beneficial for building robust and performant applications in Go. It adheres to standard Go module practices.

Quickstart example

This quickstart example demonstrates how to fetch the latest transactions for a specific wallet address using the Covalent JavaScript SDK. An API key is required to make requests.

JavaScript example: Get latest transactions

import { CovalentClient } from "@covalent/client";

const API_KEY = "YOUR_COVALENT_API_KEY"; // Replace with your actual Covalent API key
const client = new CovalentClient(API_KEY);

async function getWalletTransactions(chainId, walletAddress) {
  try {
    const response = await client.BalanceService.getHistoricalTransactionsForAddress(
      chainId,
      walletAddress
    );
    console.log(`Transactions for ${walletAddress} on chain ${chainId}:`);
    if (response.data && response.data.items) {
      response.data.items.forEach(tx => {
        console.log(`  Tx Hash: ${tx.tx_hash}, Value: ${tx.value}, Block: ${tx.block_height}`);
      });
    } else {
      console.log("No transactions found or data format unexpected.");
    }
  } catch (error) {
    console.error("Error fetching transactions:", error.message);
  }
}

// Example usage for Ethereum Mainnet (chain ID 1) and a sample wallet address
const chainId = "1"; // Ethereum Mainnet
const sampleWalletAddress = "0xAeB2C779F5E4a09a56A35c24E7F47f4a56Fb5a04"; // A sample address

getWalletTransactions(chainId, sampleWalletAddress);

This code initializes the Covalent client with your API key, then calls the getHistoricalTransactionsForAddress method. The chainId parameter specifies the blockchain network (e.g., 1 for Ethereum Mainnet, 137 for Polygon Mainnet, as documented in Polygon Network Details). The response contains an array of transaction items, each with details such as the transaction hash, value, and block height. Error handling is included to catch potential issues during the API call.

Community libraries

While Covalent provides official SDKs, the broader developer community also contributes libraries and tools that integrate with the Covalent API. These community-driven projects can offer additional language support, specialized utilities, or integrations with other frameworks and platforms not covered by the official SDKs. For example, developers might create wrappers for specific blockchain data parsing, or build user interface components that consume Covalent data. Community contributions are often found on platforms like GitHub or through developer forums.

Developers interested in exploring community-contributed tools should search relevant repositories and forums, keeping in mind that the maintenance and compatibility of community libraries may vary. It is recommended to verify the activity and support for such projects before integrating them into production environments. Information regarding community projects and examples can sometimes be found within the Covalent developer community pages or related blockchain development forums, such as those discussing JavaScript module practices for web3 development.