APIs

Developer Docs

Introduction to Leather APIs

May 14, 2025

Disclaimer: Leather does not operate or control any third-party applications that integrate its API. Users and developers are responsible for their own implementation and due diligence when using this functionality, whether on browser or mobile.

Leather Developer API Overview

Introduction

Leather empowers developers to build apps for the Bitcoin and Stacks blockchains. Through the Leather browser extension, you can interact directly with user wallets using simple JavaScript methods. This integration supports Bitcoin-native actions and Stacks smart contract calls—all with secure user approval across desktop and mobile.

Getting Started

Detecting the Provider

In a browser environment, the Leather extension injects a global object into the window. You can detect and use it like this:

if (window.LeatherProvider) {
  // Leather is installed 🎉
  const response = await window.LeatherProvider?.request("sendTransfer", {
    recipients: [
      {
        address: "tb1qkzvk9hr7uvas23hspvsgqfvyc8h4nngeqjqtnj",
        amount: "10000",
      }
    ]
  });
}

This follows the .request method standard from the Modern Wallet APIs proposal.

Core Methods

  • getAddresses: Get Bitcoin (SegWit, Taproot) and Stacks addresses.

  • signMessage: Sign an arbitrary message with a Bitcoin address.

  • sendTransfer: Sign and broadcast a Bitcoin transaction.

  • signPsbt: Sign and broadcast a PSBT.

  • Stacks Libraries: Interact with Stacks smart contracts and assets.

TypeScript Support

If you're working in a TypeScript environment, Leather provides type definitions via the @leather.io/rpc package. This package declares LeatherProvider on the global object and types its available methods and responses for better developer experience.

Installation

You can install the typings package using your preferred package manager:

npm install -D @leather.io/rpc
# or
yarn add -D @leather.io/rpc
# or
pnpm add -D @leather.io/rpc

Once installed, you'll benefit from autocomplete and type checking when interacting with the Leather API in your web app or extension.