Docs / Developer API
Developer API
Read Sapling data, and plant, buy, sell and claim Sapling coins from your own app, bot or terminal, with your users' own Solana wallets.
What it is
A JSON API over the same index and the same transaction builders sapling.cash uses. Every transaction comes back unsigned: your user's wallet signs it, and Sapling never holds a key.
There is no referral and no integrator cut. A coin planted or traded through the API pays exactly what a coin planted on sapling.cash pays: 2.00% creator fee, split 25% LP, 25% rootstock, 10% treasury and 40% to the deployer's choice. The split is not in the API: it is enforced on chain, for every trade from anywhere. How.
Base URL
https://api.sapling.cash/v1JSON in and out. No key is needed, to read or to plant or trade. A key raises your limits and gives you usage stats: make one with your wallet, and send it in the Authorization header.
A first read
The five trending coins:
curl "https://api.sapling.cash/v1/coins?sort=trending&limit=5"With a key:
curl "https://api.sapling.cash/v1/coins?sort=trending&limit=5" \
-H "Authorization: Bearer $SAPLING_API_KEY"Amounts are base units as strings: "25000000" is 0.25 ZEC. See amounts.
A first buy
The SDK builds the transaction through the API, checks it on your side against your own request, signs it and sends it.
npm install @saplingcash/sdkimport { Keypair } from "@solana/web3.js";
import { Sapling } from "@saplingcash/sdk";
const sapling = new Sapling({ apiKey: process.env.SAPLING_API_KEY, rpcUrl: process.env.RPC_URL });
const me = Keypair.fromSecretKey(mySecretKey);
// 0.25 ZEC, in base units
const buy = await sapling.buy({ wallet: me.publicKey, mint: "<mint>", pay: "ZEC", amount: 25_000_000n, slippageBps: 100 });
console.log(buy.expected); // tokens out, and the least you accept
const check = await buy.verify(); // on your machine, against your own request
if (!check.ok) throw new Error([...check.problems, ...check.transactions.flatMap((t) => t.problems)].join("; "));
await buy.sign(me);
console.log(await buy.send()); // the signatureThe same in a browser: pass the connected wallet to sign() instead of a keypair.
Where next
- Concepts: stages and venues, amounts, the fee split, why every transaction comes unsigned.
- Endpoints: every route, with a sample answer.
- Transactions: plant, trade, swap, claim, payee changes, and sending.
- Verify before you sign: what to check, and why the payee matters.
- Build it yourself: the exact planting Sapling registers, without the API.