Install
Add @thisux/dunsocial-sdk and create a client.
The package is ESM, fetch only, and runs on Node 20+, Bun, and Cloudflare Workers.
npm install @thisux/dunsocial-sdk
# bun add @thisux/dunsocial-sdk
# pnpm add @thisux/dunsocial-sdkimport { DunSocial } from '@thisux/dunsocial-sdk';
const dun = new DunSocial({
token: process.env.DUN_TOKEN,
workspaceId: process.env.DUN_WORKSPACE_ID
});
const workspaces = await dun.workspaces.list();Constructor options:
| Option | Env fallback | Notes |
|---|---|---|
token |
DUN_TOKEN |
Personal access token (dun_pat_…) |
workspaceId |
DUN_WORKSPACE_ID |
Required for workspace-scoped methods |
baseUrl |
DUN_API_URL |
Defaults to https://api.dunsocial.com |
fetch |
— | Inject for tests |
timeoutMs |
— | Defaults to 60s |
Same env names as the CLI.