The Covalent Unified API is now the GoldRush API.
Go Here

The Covalent SDK – Your New Dev Language

Covalent releases developer-friendly Typescript and Python SDKs, simplifying the blockchain development journey.
2023-08-29

TL;DR

  • Covalent has created an easy-to-use Typescript SDK and a Python SDK for modern Web3 developers.

  • HTTP requests are out, and function calls are in. Moving to the Covalent SDK is akin to upgrading from a spoon to a Swiss Army Knife.

  • Covalent is committed to enhancing the developer experience and simplifying blockchain development.

The Current Landscape at a Glance

In the rapidly evolving world of blockchain development, efficiency and flexibility are paramount. But let's face it, working with raw HTTP interfaces in blockchain can be like using a single primitive tool for every task. It involves manual handling of security, connection, and data processing – a cumbersome, time-consuming process lacking the finesse modern developers crave. Unfortunately, many developers resort to creating their own makeshift internal clients, which often lack the finesse and features of a standardized solution. These internal clients frequently miss out on keeping up with emerging APIs and often underdeliver on caching and error management. Our mission at Covalent is clear: reduce busy work and elevate the developer experience.

The Search for the Right Development Tool

Creating the perfect development toolkit for the blockchain era is akin to designing a Swiss Army Knife explicitly tailored for modern developers. What developers crave is a tool that offers the versatility, complexity, and adaptability of a Swiss Army Knife yet remains as user-friendly and approachable as their familiar coding environment. Accomplishing this means embracing a multitude of challenges like versatility across protocols, grouping diverse functionalities, and balancing the powerful and the practical. These hurdles have kept developers tethered to outdated methods—until now.

Introducing the Covalent SDK, a Modern Tool Designed Specifically for Modern Devs

Moving away from the limitations of raw HTTP interfaces, the Covalent SDK is like a Swiss Army Knife, opening up a world of efficiency and flexibility. The Covalent SDK allows you to easily access the Covalent Unified API through a programmer-friendly interface, with comprehensive support for all Class A, Class B, and Pricing endpoints grouped under various Services.

The JavaScript environment enables you to use function calls instead of GET requests and seamlessly integrate all chains across mainnets and testnets. This streamlines the development process, enabling developers to focus more on innovation and less on the repetitive tasks associated with HTTP interfaces. It's a step towards a more elegant and effective way of blockchain development, aligning with the evolving needs of the tech-savvy developer.

SDK vs Traditional HTTP Request: A Side-by-Side Comparison

Making an HTTP Request Without the SDK

In traditional JavaScript code without the SDK, developers typically use libraries like Axios or the built-in fetch method to make HTTP requests. This requires manually setting up the URL, headers, authentication, and response handling. Here's an example:

fetch('https://api.covalenthq.com/v1/eth-mainnet/address/{walletAddress}/balances_v2/', { headers: { 'Content-Type': 'application/json', 'Authorization': 'Basic ' + btoa('YOUR_API_KEY:') } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('There was an error!', error));

Making the Same Request Using the Covalent SDK

With the Covalent SDK, the same request is wrapped into an intuitive function call, abstracting the underlying HTTP complexity:

import { Client } from "@covalenthq/client-sdk"; const client = new Client("YOUR_API_KEY"); const response = await client.BalanceService.getTokenBalancesForWalletAddress("eth-mainnet", "WALLET_ADDRESS"); if (!response.error) { console.log(response.data); } else { console.log(response.error_message); }

What Makes the SDK Easier?

  1. Intuitive Function Calls: You use descriptive function calls aligned with your tasks rather than manually constructing URLs and headers.

  2. Built-In Authentication: You don't need to worry about manually setting up authorization headers.

  3. Error Handling: Errors are standardized and can be handled more consistently.

  4. Consistent Structure: All API endpoints are accessed in a uniform way, making the codebase more maintainable and readable.

  5. Function Generators vs. Pagination: Lastly, the Covalent SDK offers function generators as an alternative to traditional pagination. Rather than making individual requests for each page, developers can leverage these generators, built on idiomatic code principles, to automate data fetching. They continuously loop through the pages, extracting data until the whole dataset is acquired. This is a much more streamlined, efficient method to handle vast amounts of data, and a more intuitive experience for developers.

For Python developers, we’ve also created the Covalent API SDK supported for Python. Like the Typescript SDK, it covers the entire suite of Class A, Class B, and Pricing endpoints grouped by service, and supports all chains across mainnets and testnets. Check it out here.

Getting Started

First, make sure you have a Covalent API key. You can sign up for one here and use the key created under the API Keys tab in your user dashboard.

Typescript

Find the SDK here:

Then, install the app using the command:

npm install @covalenthq/client-sdk

or

yarn add @covalenthq/client-sdk

After installing the app, you can then import and use the SDK:

import { Client } from "@covalenthq/client-sdk"; const ApiServices = async () => { const client = new Client("YOUR_API_KEY"); // Replace with your Covalent API key. const resp = await client.BalanceService.getTokenBalancesForWalletAddress("eth-mainnet", "WALLET_ADDRESS"); // Example call, refer to API Docs for required paramaters or click into the method `getTokenBalancesForWalletAddress` to see the accepted parameter arguments if (!resp.error) { console.log(resp.data); } else { console.log(resp.error_message); } }

Python

Find the SDK here:

Then, install the app using the command:

pip3 install covalent-api-sdk

After installing the app, you can then import and use the SDK:

from covalent import Client
def main(): c = Client("YOUR_KEY") b = c.balance_service.get_token_balances_for_wallet_address("eth-mainnet", "demo.eth") if not b.error: print(b.data.chain_name) else: print(b.error_message)

Covalent's Commitment to Improving the Developer Experience

Covalent's deep expertise in the blockchain API field situates us perfectly to provide this cutting-edge SDK. Our commitment to developer-friendly solutions, track record of success, and continued understanding of developers' needs have led us here. We're not just speaking your language; we're revolutionizing it.

It transformed my workflow, turning complex tasks into simple function calls. It's a game-changer!

From HTTP to Simplified Blockchain Development

The Covalent SDK is our response to the real challenges developers face. We know what it's like to wrestle with the challenges of HTTP interfaces, and we wanted to create something better—the Swiss Army Knife for the modern developer. We're excited about what this can mean for innovation and efficiency, but we don't have all the answers. So we invite you to try out the Covalent SDK, join our community, and help us shape the future together. Your feedback, your expertise, and your passion are what will truly make this tool revolutionary.

Read more

Join the verifiable data mission today.