Two halves, one client. cs.create(userId) opens a session for one end user; cs.api is the REST client on the same key, base URL and project scope. Nothing is configured twice.
A charge in sixty seconds
import { } from "@codespar/sdk";
const = new ({ : .. });
const = await .("user_0000", { : "brazilian" });
try {
const charge = await .({ : 150,
: "BRL",
: "pix",
: "Order 0000",
: { : "Example Buyer" },
});
.(.);
} finally {
await .();
}Amounts follow the wire, and the two halves differ. charge takes major units, so R$ 150.00 is 150. PayArgs, ledger legs and every *_minor field take minor units, so R$ 1.50 is 150. Timeouts are milliseconds in this package and seconds in the Python one.
The same money over REST
cs.api is on the client you already built: same key, same base URL, same project scope. The path and the shape of both arguments are checked against the served document, so a wrong parameter name is a type error rather than a 400.
const wallet = await ..("/v1/wallets/{id}", { : { : "wlt_0000000000000000" },
});Every operation the API serves has a call like this one. The REST client pages list them by resource group, the same grouping the HTTP reference uses.
Reading a method page
Each method opens with a bar that says what kind of call it is, whether it can move money, the version it appeared in and the Python name; below it come the parameters, an example, the result type and what it throws. Every method also takes a trailing opts?: CallOptions ({ timeout, signal }), documented once on the client page.