☞ The renaming of “Ledger Live” to “Ledger Wallet” is still in progress in the repos.
This page may contain references to “Ledger Live” that will be updated soon.
How to initialize and use the Ledger Wallet API
Goal
Initialize the Ledger Wallet API Core client, connect to a transport, and perform basic interactions (e.g., read accounts), then cleanly disconnect.
Installation
You can use your favorite package manager to install @ledgerhq/wallet-api-client:
npm install @ledgerhq/wallet-api-clientStep 1 - Initialize the transport
Set up the WindowMessageTransport (provided by @ledgerhq/wallet-api-core and re-exposed by @ledgerhq/wallet-api-client) to enable communication between your app and Ledger devices.
Step 2 - Create and initialize the client
Use the transport to initialize WalletAPIClient.
import {
WalletAPIClient,
WindowMessageTransport,
} from "@ledgerhq/wallet-api-client";
async function initializeWalletApiClient() {
// 1) Connect the Window Message Transport
const windowMessageTransport = new WindowMessageTransport();
windowMessageTransport.connect();
// 2) Initialize the Wallet API Client
const walletApiClient = new WalletAPIClient(windowMessageTransport);
// 3) Use the client (example: list accounts)
// const accounts = await walletApiClient.account.getAccounts();
// Your application logic here...
// 4) Disconnect when done
windowMessageTransport.disconnect();
}
// Execute the function
initializeWalletApiClient().catch((error) => console.error(error));Step 3 - Disconnect when finished
Always close the communication channel by calling disconnect on the transport after your operations are complete.
Outcome
You have a connected Ledger Wallet API client and can call methods such as account.getAccounts() to interact with Ledger devices.
Next steps
- Explore available methods in the API reference to retrieve accounts, request signatures, and perform transactions.
- Integrate error handling and UI flows for device connection states.