Skip to main content
Welcome to the Spark API Reference documentation. This comprehensive guide covers all the methods available in the Spark SDKs for building Bitcoin-native applications, including wallet management, Bitcoin operations, Lightning Network integration, and token issuance.

Available SDKs


Getting Started

To get started with the Spark API, follow the steps below.
1

Install the SDK

Install the SDK package using your package manager of choice.For the Wallet SDK:
npm install @buildonspark/spark-sdk
For the Issuer SDK:
npm install @buildonspark/issuer-sdk
2

Initialize a Wallet

Create a wallet instance to start interacting with the Spark network.For the Wallet SDK:
import { SparkWallet } from "@buildonspark/spark-sdk";

async function main() {
  const { wallet, mnemonic } = await SparkWallet.initialize({
    options: { network: "MAINNET" },
  });
  const address = await wallet.getSparkAddress();
  console.log({ address });
}

main();
For the Issuer SDK:
import { IssuerSparkWallet } from "@buildonspark/issuer-sdk";

async function main() {
  const { wallet, mnemonic } = await IssuerSparkWallet.initialize({
    options: { network: "MAINNET" },
  });
  const address = await wallet.getSparkAddress();
  console.log({ address });
}

main();
3

Explore Documentation

Browse the method documentation using the sidebar navigation. Each method includes detailed parameters, return values, and code examples.

Error Handling

The SDK throws typed errors that you can catch and handle appropriately:
import { 
  SparkError, 
  SparkValidationError, 
  SparkRequestError 
} from "@buildonspark/spark-sdk";

try {
  await wallet.transfer({ receiverSparkAddress: "...", amountSats: 1000 });
} catch (error) {
  if (error instanceof SparkValidationError) {
    // Invalid parameters (e.g., negative amount, invalid address format)
    console.error("Validation error:", error.message);
    console.error("Field:", error.context?.field);
  } else if (error instanceof SparkRequestError) {
    // Network/API errors
    console.error("Request failed:", error.message);
  } else if (error instanceof SparkError) {
    // General SDK errors
    console.error("SDK error:", error.message);
  }
}
Error TypeWhen Thrown
SparkValidationErrorInvalid parameters, out-of-range values, format errors
SparkRequestErrorNetwork failures, API errors, timeout
SparkErrorGeneral SDK errors, configuration issues

Use AI Tools with These Docs

Our documentation is optimized for AI coding assistants like Cursor, Claude, and ChatGPT.
ResourceURL
Full docs (LLM-optimized)docs.spark.money/llms-full.txt
Docs indexdocs.spark.money/llms.txt
Any page as MarkdownAppend .md to any URL
Paste the llms-full.txt URL into your AI assistant’s context for complete knowledge of Spark’s APIs and best practices.