npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bol-com-sdks

v0.2.0

Published

Unofficial TypeScript SDKs for the bol.com catalog, affiliate reports and FTPS product feeds

Downloads

469

Readme

Bol.com SDKs

An unofficial TypeScript SDK for the bol Marketing Catalog API, Affiliate Reports API and product feed. Requires Node.js 22+ and TypeScript 5.9+ for TypeScript consumers. ESM only.

Install

npm install bol-com-sdks

TypeScript applications using the Node-only feed entrypoint should also install @types/node.

Catalog

import { createCatalogClient, createTokenProvider } from 'bol-com-sdks';

const token = createTokenProvider({
  clientId: process.env.BOL_CLIENT_ID!,
  clientSecret: process.env.BOL_CLIENT_SECRET!,
});
const catalog = createCatalogClient({ token, country: 'NL', language: 'nl' });

const product = await catalog.products.get('0842776106209', {
  includeOffer: true,
  includeImage: true,
});
console.log(product.title, product.offer?.price);

Resource methods return the generated response model directly and throw on HTTP failures. Country and language defaults are explicit client settings. Methods that use them accept per-call country and language overrides. Options use camelCase; the SDK handles wire parameter names and array serialization.

All ten catalog operations are available:

await catalog.products.get('0842776106209', { includeSpecifications: true });
await catalog.products.getBestOffer('0842776106209', { includeSeller: true });
await catalog.products.getMedia('0842776106209');
await catalog.products.getRatings('0842776106209');
await catalog.products.getCategories('0842776106209', { language: 'fr-BE' });
await catalog.products.getVariants('0842776106209', { country: 'BE' });
await catalog.products.getRecommendations('0842776106209');
await catalog.products.resolveEan('9200000099487092');

const page = await catalog.products.search({
  searchTerm: 'books',
  page: 1,
  pageSize: 25,
  sort: 'PRICE_ASC',
  includeOffer: true,
});
const popular = await catalog.products.listPopular({ categoryId: '4770' });

EANs and bol product IDs are strings. This preserves leading zeros and large IDs. The public model aliases, such as Product and SearchPage, reference the checked-in OpenAPI types. They are not separate handwritten response definitions.

Pagination

Use search and listPopular for a single page, or lazy async iterators to traverse products:

for await (const product of catalog.products.searchAll({
  searchTerm: 'books',
  pageSize: 25,
  includeOffer: true,
})) {
  console.log(product.title);
  if (product.ean === '0842776106209') break;
}

for await (const product of catalog.products.popularAll({ categoryId: '4770' })) {
  console.log(product.ean);
}

Iteration starts at page, or page 1, preserves the supplied filters and fetches the next page only when needed. It stops at totalPages or an empty page. Breaking iteration fetches no more pages. Malformed continuation metadata causes an error. The SDK does not collect all products in memory. Catalog page numbers must be positive integers; page sizes must be between 1 and 50.

Affiliate reports

import { createReportsClient } from 'bol-com-sdks';

// Reuse the token provider above to share cached tokens across HTTP clients.
const reports = createReportsClient({ token });
const period = { startDate: '2026-01-01', endDate: '2026-01-31' };

const orders = await reports.orders.get(period);
const promotions = await reports.promotions.get(period);
const commissions = await reports.commissions.get(period);
console.log(orders.items);

Report dates must be valid YYYY-MM-DD strings in ascending order. Reports return their documented models, including items; there is no invented pagination or date-range splitting.

Authentication, request controls and errors

Keep client credentials on your server. The token provider caches access tokens for 90% of their reported lifetime and shares concurrent refresh requests. A failed refresh can be attempted again by a later call. Cancelling one request does not cancel a token refresh shared with other callers. A token string or your own asynchronous token provider is also accepted.

Request options are separate from domain parameters:

import { BolApiError, BolConnectionError, BolDecodingError } from 'bol-com-sdks';

try {
  const product = await catalog.products.get('0842776106209', {}, {
    signal: AbortSignal.timeout(10_000),
    timeoutMs: 5_000,
    onResponse: ({ status, requestId, headers }) => {
      console.log(status, requestId, headers.get('content-type'));
    },
  });
} catch (error) {
  if (error instanceof BolApiError) {
    console.error(error.status, error.requestId, error.retryAfter, error.body);
  } else if (error instanceof BolConnectionError) {
    console.error(error.cause);
  } else if (error instanceof BolDecodingError) {
    console.error(await error.response?.text());
  } else {
    throw error;
  }
}

The client deadline defaults to 30 seconds. Per-request timeoutMs overrides it for resource methods, including reading the response body. For methods without domain options, request options are the second argument, for example getMedia(ean, request). During iteration the timeout applies separately to each page, while signal can cancel the whole traversal. OAuth acquisition has its own configurable deadline. Timeouts use TimeoutError; cancellation preserves the signal's reason. Custom Fetch implementations must honor the supplied AbortSignal.

BolApiError preserves the raw Response and parsed error body, or text for non-JSON errors. BolConnectionError preserves the underlying cause. BolDecodingError preserves the response where available. Token endpoint HTTP failures throw AuthenticationError with a status, without copying potentially sensitive error bodies. Invalid caller input fails before sending a request and may throw synchronously. onResponse runs for successful responses, HTTP errors and JSON decoding errors after body reading; callback exceptions propagate.

No request is retried automatically. In particular, bol instructs clients not to automatically retry catalog HTTP 500 responses. Inspect status and retryAfter when implementing an application-specific policy. Rejected bearer tokens are not automatically refreshed or replayed. Inject fetch and a trusted baseUrl for testing or proxying.

Validation policy

The SDK validates credentials, deadlines, EAN shape, page bounds, report dates, token responses, JSON object responses and pagination continuation fields. It does not deeply validate catalog/report response models. Unknown response fields and enum values are preserved rather than rejected. Compile-time types describe the pinned specification; they cannot guarantee that bol's live implementation matches it. Successful JSON objects are checked at the boundary and then decoded by the generated transport. This reads JSON twice and retains a raw Response for decoding diagnostics.

Advanced HTTP access

Each HTTP client exposes .raw, the underlying typed openapi-fetch interface. It accepts wire parameters and returns { data, error, response } unions. Resource methods use a separate transport instance, so middleware registered on .raw does not change their behavior.

const result = await catalog.raw.GET('/marketing/catalog/v1/products/{ean}', {
  params: {
    path: { ean: '0842776106209' },
    query: { 'country-code': 'NL' },
    header: { 'Accept-Language': 'nl' },
  },
});

The raw interface does not apply resource validation or configured catalog locale defaults. Its errors and parsing follow openapi-fetch semantics. Use it when access to the wire contract is useful.

Product feed

import { ProductFeedClient } from 'bol-com-sdks/product-feed';

const feed = new ProductFeedClient({
  user: process.env.BOL_FEED_USER!,
  password: process.env.BOL_FEED_PASSWORD!,
});
const files = await feed.list();
console.log(files.map(file => file.name));
// Substitute an actual remote path returned by the server.
await feed.download('remote-file-name', './feed-download');

The feed uses separate credentials and requires your public IP to be whitelisted in the bol dashboard. Activation can take one hour. Connections use explicit FTPS with certificate verification at apm-feed.unftp.bol.com:21. Each operation owns and closes its connection, including on failure. HTTP-only imports do not load basic-ftp.

Downloads write raw bytes to a local filename or Node Writable stream with bounded memory. Existing local files can be overwritten, and failed transfers can leave partial files. Compression and feed parsing remain the caller's responsibility. The configurable 30-second FTP socket timeout is not a total transfer deadline. FTP errors retain basic-ftp/Node semantics; HTTP request options and error classes do not apply to feed operations.

Development and compatibility

npm run generate      # Regenerate the checked-in wire types
npm run check         # Strict type checks, protocol tests, build
npm run test:package  # Install the tarball in a temporary consumer and verify it

CI runs on Node.js 22 and 24, checks generated files for drift and verifies packed runtime imports plus TypeScript consumers using NodeNext and Bundler resolution. Protocol tests cover all resource routes, serialization, token refresh and cancellation races, pagination, errors, deadlines and mocked FTP cleanup. A local HTTP server tests a stalled body. No authenticated live Bol or real FTPS integration test has been run.

Spec snapshots record URLs, retrieval dates and checksums in specs/manifest.json. Deterministic regeneration checks local drift, not upstream changes or live compliance. Review upstream specs before updating snapshots and review public API changes before release. The generator is locked through package-lock.json; TypeScript 5.9 matches its declared support.

Version 0.2 changes the earlier 0.1 API. See CHANGELOG.md. During 0.x, breaking changes use a minor version; patches remain compatible. From 1.0, incompatible public types, exports, error behavior or runtime requirements require a major release. Keep changelogs and migration guidance for breaking changes. Node.js ESM is the supported runtime; other runtimes and CommonJS have not been promised or tested.

Sources