> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spark.money/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Spark SDK methods for wallets, Lightning, and token issuance.

export const Card = ({icon, iconLight, iconDark, href, title, description, target = "_self"}) => {
  return <div className="spark-card rounded-2xl flex justify-center p-4 hover:scale-[1.02] transition-all duration-300">
      <a href={href} target={target} rel={target === "_blank" ? "noopener noreferrer" : undefined} className="w-full">
        <div className="flex flex-col gap-12 justify-space-between">
          <div className="w-8 h-8">
            {iconLight && iconDark ? <>
                <img src={iconLight} className="icon-light w-full h-full pointer-events-none" alt={title} width={32} height={32} />
                <img src={iconDark} className="icon-dark w-full h-full pointer-events-none" alt={title} width={32} height={32} />
              </> : <img src={icon} className="w-full h-full pointer-events-none" alt={title} width={32} height={32} />}
          </div>
          <div className="flex flex-col gap-2">
            <h2 className="card-title text font-semibold leading-tight">
              {title}
            </h2>
            <p className="card-description text-sm leading-tight">
              {description}
            </p>
          </div>
        </div>
      </a>
    </div>;
};

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

<Columns cols={2} className="gap-4">
  <Card icon="https://mintcdn.com/lightspark/y_i-zvoD8RGnL1Jv/icons/icon-wallet-purple.svg?fit=max&auto=format&n=y_i-zvoD8RGnL1Jv&q=85&s=7c9cd193f12a1a40afbba47665a0b3bc" href="/api-reference/wallet-overview" title="Wallet SDK" description="Create wallets, handle deposits, transfers, and Lightning payments" width="16" height="16" data-path="icons/icon-wallet-purple.svg" />

  <Card icon="https://mintcdn.com/lightspark/QeKlW2AmFua1qq8H/icons/icon-coins-greenbright.svg?fit=max&auto=format&n=QeKlW2AmFua1qq8H&q=85&s=cdb73f14131c80233c85bd0b7f5473a9" href="/api-reference/issuer-overview" title="Issuer SDK" description="Issue tokens, mint, burn, and manage token lifecycles" width="16" height="16" data-path="icons/icon-coins-greenbright.svg" />
</Columns>

***

## Getting Started

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

<Steps>
  <Step title="Install the SDK">
    Install the SDK package using your package manager of choice.

    For the **Wallet SDK**:

    <CodeGroup>
      ```bash npm theme={null}
      npm install @buildonspark/spark-sdk
      ```

      ```bash yarn theme={null}
      yarn add @buildonspark/spark-sdk
      ```

      ```bash pnpm theme={null}
      pnpm add @buildonspark/spark-sdk
      ```
    </CodeGroup>

    For the **Issuer SDK**:

    <CodeGroup>
      ```bash npm theme={null}
      npm install @buildonspark/issuer-sdk
      ```

      ```bash yarn theme={null}
      yarn add @buildonspark/issuer-sdk
      ```

      ```bash pnpm theme={null}
      pnpm add @buildonspark/issuer-sdk
      ```
    </CodeGroup>
  </Step>

  <Step title="Initialize a Wallet">
    Create a wallet instance to start interacting with the Spark network.

    For the **Wallet SDK**:

    ```ts theme={null}
    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**:

    ```ts theme={null}
    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();
    ```
  </Step>

  <Step title="Explore Documentation">
    Browse the method documentation using the sidebar navigation. Each method includes detailed parameters, return values, and code examples.
  </Step>
</Steps>

***

## Error Handling

The SDK throws typed errors that you can catch and handle appropriately:

```typescript theme={null}
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);
    const { field } = error.getContext() as { field?: string };
    console.error("Field:", 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 Type             | When Thrown                                            |
| ---------------------- | ------------------------------------------------------ |
| `SparkValidationError` | Invalid parameters, out-of-range values, format errors |
| `SparkRequestError`    | Network failures, API errors, timeout                  |
| `SparkError`           | General SDK errors, configuration issues               |

***

## Use AI Tools with These Docs

Our documentation is optimized for AI coding assistants like Cursor, Claude, and ChatGPT.

| Resource                  | URL                                                                      |
| :------------------------ | :----------------------------------------------------------------------- |
| Full docs (LLM-optimized) | [docs.spark.money/llms-full.txt](https://docs.spark.money/llms-full.txt) |
| Docs index                | [docs.spark.money/llms.txt](https://docs.spark.money/llms.txt)           |
| Any page as Markdown      | Append `.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.
