@dobprotocol/sdk
TypeScript client for DobProtocol. One package, two clients:
createClient({ apiKey }) — API-key client over /api/sdk/*: pool queries,
Stellar marketplace (buy/sell/list), exit liquidity, widgets, projects. This is
what DobLink (link.dobprotocol.com) uses. Keys: link.dobprotocol.com/dashboard/api-keys.
new DobProtocolClient({ network }) — wallet-auth client over the main
/api/* routes: sign in with a Stellar wallet, create and operate pools. Documented at
docs.dobprotocol.com.
Install
npm install @dobprotocol/sdk
npm install @stellar/freighter-api
Source lives here (Dobprotocol/Doblink, packages/sdk); DobLink's Landing/
consumes it through a tsconfig path alias. Publishing: npm run publish:prod
(see scripts/publish.sh).
Quick start — createClient
import { createClient } from "@dobprotocol/sdk";
const dob = createClient({
apiKey: process.env.DOB_API_KEY!,
baseUrl: "https://home.dobprotocol.com",
});
const pools = await dob.pools.listPublic({ page: 1, pageSize: 20 });
const listings = await dob.stellar.getPoolListings(poolAddress, 9);
import { signXdrWithFreighter } from "@dobprotocol/sdk/freighter";
const { xdr } = await dob.marketplace.prepareBuy({
userPublicKey: "G...",
contractId: poolAddress,
sellerAddress: "G...",
sharesAmount: 10,
network_id: 9,
});
const signedXdr = await signXdrWithFreighter(xdr, { network_id: 9 });
const { transactionHash } = await dob.marketplace.submitBuy({ signedXdr, network_id: 9 });
Modules
dob.pools — list/search/get pools, creator pools, distributions
dob.stellar — balances, listings, stats, price history, full pool lifecycle (deploy/initialize/deposit/distribute/transfer/withdraw)
dob.marketplace — buy / list / cancel on Stellar
dob.exitLiquidity — LP offers, instant sell, add/remove liquidity
dob.widgets — DobLink widget CRUD + analytics + view tracking
dob.projects — project CRUD
Networks
import { NETWORKS, marketplaceAvailable } from "@dobprotocol/sdk";
NETWORKS.STELLAR_MAINNET.id;
NETWORKS.BASE_MAINNET.id;
marketplaceAvailable(8453);
Errors
import { DobError, DobAuthError, DobNotSupportedError } from "@dobprotocol/sdk";
All request failures throw DobError (or a subclass) with code, status, and
the parsed response body on .details.
DobProtocolClient
import { DobProtocolClient } from "@dobprotocol/sdk";
const dob = new DobProtocolClient({ network: "mainnet" });
const pools = await dob.pools.getPublicPools({ limit: 5 });
const pool = await dob.pools.getPool("C...");
Full reference: docs.dobprotocol.com → DobLink → SDK reference. Where both clients
define a type with the same name (MarketplaceStats, Project, Widget), the bare
export is the DobProtocolClient shape and the createClient one is prefixed
Link* (LinkMarketplaceStats, LinkProject, LinkWidget).