Skip to content

TypeScript ​

Package: @valeryverkhoturov/wb-api-client on npm.

  • Node: 18+
  • HTTP: axios
  • Types: first-class TypeScript, ships .d.ts
  • Secret wrapper: inlined SecretString class

Install ​

bash
npm install @valeryverkhoturov/wb-api-client
bash
pnpm add @valeryverkhoturov/wb-api-client
bash
yarn add @valeryverkhoturov/wb-api-client
bash
bun add @valeryverkhoturov/wb-api-client

Import shape ​

Every sub-module is a subpath export. Import from @valeryverkhoturov/wb-api-client/<slug>:

ts
import {
  Configuration,
  ItemsApi,
} from "@valeryverkhoturov/wb-api-client/items";

You never import from the root @valeryverkhoturov/wb-api-client — there's no barrel to avoid pulling in 13 SDKs when you only need one.

Sub-modules ​

Sub-path per category:

general, items, orders_fbs, orders_dbw, dbs, in_store_pickup, orders_fbw, promotion, communications, rates, analytics, reports, finances.

Full list of Api classes per module lives in the per-release README: clients/typescript/README.md.

Auth ​

ts
import { Configuration, ItemsApi } from "@valeryverkhoturov/wb-api-client/items";

const cfg = new Configuration({});
cfg.setAccessToken("<your WB JWT>");
const api = new ItemsApi(cfg);

const res = await api.someEndpoint();
console.log(res.data);

The setAccessToken method wraps the value in a SecretString internally. Direct assignment (cfg.accessToken = "...") is not supported — always go through the setter so redaction is guaranteed.

To read the raw value back (e.g. for a diagnostic log):

ts
cfg.accessToken.exposeSecret();

User-Agent ​

The client sends ValeryVerkhoturov/wb-api-client/typescript on every request — WB uses this as a coarse-grained routing signal. To add your own app identifier without replacing it:

ts
const cfg = new Configuration({});
cfg.setAccessToken(TOKEN);
cfg.baseOptions = {
  ...cfg.baseOptions,
  headers: {
    ...cfg.baseOptions.headers,
    "User-Agent":
      "MyApp/1.2.3 (+https://myapp.example) ValeryVerkhoturov/wb-api-client/typescript",
  },
};

ESM / CJS ​

The package publishes dual entry points — import from ESM code, require from CommonJS. TypeScript "module": "NodeNext" or "module": "bundler" in your tsconfig.json picks the right one automatically.

Bundler support ​

The subpath exports are declared in package.json exports. Modern bundlers (Vite, Rollup, esbuild, Webpack 5+, Turbopack) respect them out of the box. Webpack 4 does not — upgrade or add a manual alias.

Testing ​

Point at a mock server via basePath:

ts
const cfg = new Configuration({ basePath: "http://localhost:8080" });

See also ​

wb-api-client mascot