@brandazine/solari-sdk
v0.2.2
Published
TypeScript client for the SOLARI API — creator and brand intelligence across Instagram and TikTok.
Readme
@brandazine/solari-sdk
TypeScript client for the SOLARI API — creator and brand intelligence across Instagram and TikTok. Zero dependencies; runs on Node 18+, Bun, Deno, Cloudflare Workers, and browsers with fetch.
npm install @brandazine/solari-sdkQuickstart
import { Solari } from "@brandazine/solari-sdk";
const solari = new Solari({ token: process.env.SOLARI_TOKEN });
const hits = await solari.tools.catalog.instagram.account.search({ query: "nike", limit: 3 });
const brand = await solari.tools.insight.instagram.brand.overview({ username: "nike" });
const tools = await solari.listTools();Create an API key on your SOLARI My page (long-lived, solari_sk_…, shown once), or mint a short-lived token with solari auth token on a machine signed in to the solari CLI. With no token option the client reads SOLARI_TOKEN.
Typed tools
solari.tools is generated from the SOLARI tool registry, so every tool path, argument name, argument type, and enum value is checked by the TypeScript compiler and completed by your editor. A missing required argument, a misspelled key, or an out-of-range enum fails at compile time.
await solari.tools.catalog.instagram.account.search({ query: "nike", query_type: "bio" });
await solari.tools.catalog.instagram.account.search({ limit: 3 }); // error: query is required
await solari.tools.catalog.instagram.account.search({ query: "nike", query_type: "fuzzy" }); // error: not an enum valueTool responses are JSON whose shape is documented per tool at solari.sh/docs; pass a type parameter to name it: search<AccountHits>({ ... }).
solari.call(name, args) checks the arguments the same way when name is one of the generated SolariToolName values. Any other name — for example the per-account solari_apps_* tools — is accepted with free-form arguments, and solari.dynamic.<any>.<path>(args) spells such a call as a path without type checking.
API
new Solari({ token?, baseUrl?, fetch?, timeoutMs?, userAgent? })—baseUrldefaults tohttps://solari.sh;fetchlets you inject a custom implementation.solari.tools.<family>.<platform>.<group>.<name>(args)— typed tool calls; segments mirror thesolari_tool names.solari.call<T>(name, args)— run a tool by name and get its JSON payload back.solari.listTools()— every tool the signed-in account can call, with its JSON input schema.solari.getTool(name)— one tool.solari.me()— the identity behind the token.solari.dynamic— untyped path proxy for tools that are not in the generated catalog.SOLARI_TOOL_NAMES,SolariToolName,SolariToolMap,SolariTools,<Tool>Args— the generated types.
Errors throw SolariError with status, code, message, tool, retryAfterSeconds, and a retryable flag (429, 502, 503, 504). Codes come straight from the API: invalid_arguments, tool_not_found, rate_limited, forbidden, upstream_timeout, app_warming_up, ...
Development
bun install
bun run typecheck
bun test
bun run buildsrc/tools.generated.ts is produced from the MCP worker's tool registry by pnpm run sdk:generate in cf-workers/solari-mcp; CI fails when it is stale.
