Skip to main content

Quickstart: Make your first API call

info

These steps assume you already have a Coinbase Developer Platform account. Please sign up here if not.

This Coinbase Staking Quickstart will walk you through installing our API client and making your first API call to our ListProtocols endpoint. Our native clients provide access to all API features and are written for easy integration to your backend.

1. Set up a workspace

In your preferred command shell, let's get started by creating a new workspace directory staking-demo and navigating to it.

mkdir staking-demo
cd staking-demo

2. Install the pre-requisites

Install the following prerequisites and dependency packages for your chosen language.

The Ts staking client requires installation of Node (version 20+) before proceeding ahead.

Once you have node and npm installed, you can install the following packages using the command below.

npm install ts-node typescript

3. Setup API access

warning

Ensure you keep your API key file secure and do not share it with anyone. If you suspect your key has been compromised, you can regenerate it in the CDP portal and/or mark the compromised key as Disabled.

4. Install the Staking Client

Install the package and import it in your code to access Coinbase Staking features using a native language you're most familiar with.

npm version

npm install @coinbase/staking-client-library-ts

5. Make an API call

In the example below, you can learn how to create a StakingClient with your saved credentials and call ListProtocols to retrieve all the protocols supported by Coinbase Staking.

Create a new typescript file with the name example.ts and place it within your workspace directory staking-demo. Copy and paste the code example below into this file.

import { StakingClient } from "@coinbase/staking-client-library-ts";

const apiKeyName: string = 'your-api-key-name';
const apiPrivateKey: string = 'your-api-private-key';

const client = new StakingClient();

client.listProtocols().then((response) => {
console.log(response);
});

Run the example using ts-node. The response will be shown in your output window.

ts-node example.ts
Expected output
{
"protocols": [
{
"name": "protocols/ethereum_kiln"
},
{
"name": "protocols/solana"
}
]
}

Next Steps

For protocol specific examples and explanation of key functionality, check out their respective guides:

Was this helpful?