The official Go SDK for ln.bot — Bitcoin for AI Agents.
Give your AI agents, apps, and services access to Bitcoin over the Lightning Network. Create wallets, send and receive sats, and get real-time payment notifications.
client := lnbot.New("key_...")
invoice, _ := client.Invoices.Create(ctx, &lnbot.CreateInvoiceParams{
Amount: 1000,
Memo: lnbot.Ptr("Coffee"),
})ln.bot also ships a TypeScript SDK, Python SDK, Rust SDK, CLI, and MCP server.
go get github.com/lnbotdev/go-sdkpackage main
import (
"context"
"fmt"
lnbot "github.com/lnbotdev/go-sdk"
)
func main() {
client := lnbot.New("")
wallet, _ := client.Wallets.Create(context.Background(), &lnbot.CreateWalletParams{
Name: lnbot.Ptr("my-agent"),
})
fmt.Println(wallet.PrimaryKey)
}client := lnbot.New(wallet.PrimaryKey)
invoice, _ := client.Invoices.Create(ctx, &lnbot.CreateInvoiceParams{
Amount: 1000,
Memo: lnbot.Ptr("Payment for task #42"),
})
fmt.Println(invoice.Bolt11)events, errs := client.Invoices.Watch(ctx, invoice.Number, nil)
for event := range events {
if event.Event == "settled" {
fmt.Println("Paid!")
}
}
if err := <-errs; err != nil {
log.Fatal(err)
}payment, _ := client.Payments.Create(ctx, &lnbot.CreatePaymentParams{
Target: "alice@ln.bot",
Amount: lnbot.Ptr(int64(500)),
})wallet, _ := client.Wallets.Current(ctx)
fmt.Printf("%d sats available\n", wallet.Available)// Create a challenge (server side)
challenge, _ := client.L402.CreateChallenge(ctx, &lnbot.CreateL402ChallengeParams{
Amount: 100,
Description: lnbot.Ptr("API access"),
})
// Pay the challenge (client side)
result, _ := client.L402.Pay(ctx, &lnbot.PayL402Params{
WwwAuthenticate: challenge.WwwAuthenticate,
})
// Verify a token (server side, stateless)
v, _ := client.L402.Verify(ctx, &lnbot.VerifyL402Params{
Authorization: *result.Authorization,
})
fmt.Println(v.Valid)import "errors"
wallet, err := client.Wallets.Current(ctx)
if err != nil {
// Match any API error
var apiErr *lnbot.APIError
if errors.As(err, &apiErr) {
fmt.Println(apiErr.StatusCode, apiErr.Message)
}
// Match specific error types
var notFound *lnbot.NotFoundError
var badReq *lnbot.BadRequestError
var conflict *lnbot.ConflictError
switch {
case errors.As(err, ¬Found):
// 404
case errors.As(err, &badReq):
// 400
case errors.As(err, &conflict):
// 409
default:
// other error
}
}client := lnbot.New("key_...",
lnbot.WithBaseURL("https://api.ln.bot"),
lnbot.WithHTTPClient(customHTTPClient),
)- Zero dependencies — stdlib
net/http+encoding/jsononly - Context-first — every method takes
context.Contextas the first argument - Typed errors —
BadRequestError,NotFoundError,ConflictError,UnauthorizedError,ForbiddenError - Generic helpers —
Ptr[T]for optional fields - SSE support —
Watchreturns channels for real-time events
- Go 1.21+
- Get your API key at ln.bot
- ln.bot — website
- Documentation
- GitHub
- pkg.go.dev
- TypeScript SDK · npm
- Python SDK · pypi
- Rust SDK · crates.io · docs.rs
MIT