SDK icon
Alchemy SDK

The power of Alchemy's infrastructure. One SDK.

The Alchemy SDK is the easiest way to connect your dApp to the blockchain. Just download, write two lines of code, and you’re ready to go.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Setup: npm install alchemy-sdk
import { Alchemy } from "alchemy-sdk";
const alchemy = new Alchemy();
    
// Get the latest block
const latestBlock = alchemy.core.getBlockNumber();
   
// Get all the NFTs owned by an address
const nfts = alchemy.nft.getNftsForOwner("0xshah.eth");
   
// Listen to all new pending transactions
alchemy.ws.on(
   { method: "alchemy_pendingTransactions",
   fromAddress: "0xshah.eth" },
   (res) => console.log(res)
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Setup: npm install alchemy-sdk
import { Alchemy } from "alchemy-
sdk";
const alchemy = new Alchemy();
// Get the latest block
const latestBlock =
alchemy.core.getBlockNumber();
// Get all the NFTs owned by an
address
const nfts =
alchemy.nft.getNftsForOwner("0xshah
.eth");
Listen to all new pending
transactions
alchemy.ws.on(
  { method:
"alchemy_pendingTransactions",
  fromAddress: "0xshah.eth" },
  (res) => console.log(res));

Everything you use from Ethers - and way more

Our SDK extends Ethers.js provider, allowing you to access all the node methods you already know. However, the real magic is everything else you get for free.

Alchemy Scale and Reliability

All your requests use Alchemy’s best-in-class infrastructure that powers 70% of top dApps - meaning your requests will always succeed when you need them. Plus, you’ll get 10 million free requests every month.

NFT and Enhanced APIs

Get easy-to-use access to all of Alchemy’s Enhanced APIs with only a single line of code, including Alchemy’s coveted NFT API and Websockets. What used to take hours now takes seconds.

Multichain support

If it runs on an EVM, we support it. Access your Polygon, Optimism, Arbitrum, and Starkware nodes using the same interface and one simple config.

Quality of Life Improvements

Automatic retries? Exponential backoff? Timeout handling? Automatic query typing? The Alchemy SDK is 10x easier than calling our APIs directly.

How the Alchemy SDK Works

Dozens of lines of code are reduced to a single request - let’s take a look at how easy your life will be with the Alchemy SDK.

1
2
3
4
5
6
7
8
9
10
// Get the metadata for an NFT
  .
const nfts =
await alchemy.nft.getNftMetadata(
   "0xb47e3x71d2bfc23c34f18275bbf23bb7163BBB",
   9775
);
1
2
3
4
5
6
7
8
9
10
// Get the external transfers from an address
const transfers = await alchemy.core.getAssetTransfers
({
   category: ["external"],
   fromAddress:
"00x994b342dd879af3971dD833D26bA9b5C9366893",
});
1
2
3
4
5
6
7
8
9
10
// Listen to all new pending transactions
alchemy.ws.on(
 {
   method: "alchemy_pendingTransactions",
 fromAddress: "0xshah.eth"
 }, (res) => console.log(res)
);
1
2
3
4
5
6
7
8
9
10
// Get the balance for an address
const balance = alchemy.core.getBalance("0xshah.eth");
// Listen to all new blocks
alchemy.ws.on('block', (blockNumber) => {
console.log('New block: ' + blockNumber);
});
nft api
nft api

Get Metadata for NFTs

Grabbing NFT metadata usually requires developers to read and parse individual smart contracts, then sort through a sea of irregular data. The Alchemy NFT API and SDK makes this a one-line request.

Enhanced api
Enhanced api

Get Asset Transfers

Grabbing NFT metadata usually requires developers to read and parse individual smart contracts, then sort through a sea of irregular data. The Alchemy NFT API and SDK makes this a one-line request.

websockets
websockets

Subscribe to Pending Transactions

Grabbing NFT metadata usually requires developers to read and parse individual smart contracts, then sort through a sea of irregular data. The Alchemy NFT API and SDK makes this a one-line request.

ethers.js
ethers.js

Drop-In Functionality

Grabbing NFT metadata usually requires developers to read and parse individual smart contracts, then sort through a sea of irregular data. The Alchemy NFT API and SDK makes this a one-line request.

How the Alchemy SDK Works

Dozens of lines of code are reduced to a single request - let’s take a look at how easy your life will be with the Alchemy SDK.

1
2
3
4
5
6
7
8
9
10
// Get the metadata for an NFT
const nfts = await alchemy.getNftMetadata(
"0xb47e3x71d2bfc23c34f18275bbf23bb7163BBB",
9775
);
console.log(nfts);
1
2
3
4
5
6
7
8
9
10
// Get the external transfers from an address
const transfers = await alchemy.getAssetTransfers
({
category: ["external"],
fromAddress:
"00x994b342dd879af3971dD833D26bA9b5C9366893",
});
console.log(transfers);
1
2
3
4
5
6
7
8
9
10
// Listen to all new pending transactions
alchemy.on(
{
method: "alchemy_pendingTransactions",
fromAddress: "0xshah.eth"
},
(res) => console.log(res)
);
1
2
3
4
5
6
7
8
9
10
// Get the balance for an address
const balance = alchemy.getBalance("0xshah.eth");
"",
// Listen to all new blocks
alchemy.on('block', (blockNumber) => {
console.log('New block: ' + blockNumber);
});

How the Alchemy SDK Works

Dozens of lines of code are reduced to a single request - let’s take a look at how easy your life will be with the Alchemy SDK.

1
2
3
4
5
6
7
8
// Get the metadata for an NFT
const nfts =
await alchemy.nft.getNftMetadata(
"0x7bd...fc23c34f18275bbf23bb716bc7",
"0xb47e3x71d2bfc23c34f18275bbf23bb7163BB
B",
  9775
);
nft api

Get Metadata for NFTs

Grabbing NFT metadata usually requires developers to read and parse individual smart contracts, then sort through a sea of irregular data. The Alchemy NFT API and SDK makes this a one-line request.

1
2
3
4
5
6
7
8
// Get the external transfers from
address
const transfers = await
alchemy.core.getAssetTransfers
({ category: ["external"],
   fromAddress:
"00x...7971dD833D26bA9b5C9366893",
});
Enhanced API

Get Asset Transfers

Want to view historical transfers to or from a particular address? Get ready to scan the entire blockchain - unless you’re using Alchemy’s Enhanced APIs. We cache and return to you every transfer by an account in milliseconds.

1
2
3
4
5
6
7
8
//Listen to all new pending transactions
alchemy.on(
  {
    method: "alchemy_pendingTransactions",
  fromAddress: "0xshah.eth"
  },
(res) => console.log(res)
);
WEBSOCKETS

Subscribe to Pending Transactions

By opening a WebSocket connection, Alchemy’s SDK will send you an event every time a pending transaction is sent to or from a certain address.

1
2
3
4
5
6
7
8
// Get the balance for an address
const balance =
alchemy.core.getBalance("0xshah.eth");
await alchemy.getNftMetadata(
// Listen to all new blocks
alchemy.ws.on('block', (blockNumber) =>
{console.log('New         block:'+
blockNumber);});
Ethers.js

Drop-In Functionality

Get all the methods you know and love from Ethers.js, simply by replacing the Ethers object with an Alchemy one. One code change is all you need.

Build blockchain magic with Alchemy

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get started for free