Recombee API Client

raw JSON →
6.2.0 verified Sat Apr 25 auth: no javascript

Node.js SDK (v6.2.0) for the Recombee recommendation engine API. Provides a high-level client with batch operations, property management, and recommendation requests. Ships TypeScript types, requires Node >=18, and supports ESM & CJS. Major v6 dropped callbacks in favor of promises, and changed import paths. Regular releases on npm monthly.

error TypeError: ApiClient is not a constructor
cause Using default import instead of named import (e.g., import ApiClient from 'recombee-api-client')
fix
Use named import: import { ApiClient } from 'recombee-api-client'
error Cannot find module 'recombee-api-client'
cause Package not installed or incorrect import path in older version
fix
Run npm install recombee-api-client and ensure your node_modules includes it.
error UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
cause Client not properly instantiated with database ID and token
fix
Ensure you pass valid database ID and private token to new ApiClient(id, token, options).
error Error: Region must be one of: us-west, us-east, ap-se, eu-west
cause Invalid region string passed in options
fix
Check the Recombee documentation for valid region codes and use one of the listed values.
breaking v6.0.0 removed callback-based API; all methods now return Promises.
fix Use async/await or .then() instead of callbacks.
breaking v6.0.0 changed import structure: named exports from 'recombee-api-client' replaced default export.
fix Use import { ApiClient, requests } from 'recombee-api-client' instead of import recombee from 'recombee-api-client'.
breaking v6.0.0 requires Node >=18. Older Node versions are unsupported.
fix Upgrade Node to version 18 or later.
deprecated Using require('recombee-api-client') is deprecated; ESM import is preferred.
fix Use import { ApiClient, requests } from 'recombee-api-client' instead.
gotcha Batch requests must be sent via client.send(new requests.Batch([...])). Directly sending an array of requests does not work.
fix Wrap multiple requests in new requests.Batch() before sending.
npm install recombee-api-client
yarn add recombee-api-client
pnpm add recombee-api-client

Initializes the Recombee client with environment variables and sends a ListUsers request.

import { ApiClient, requests } from 'recombee-api-client';

const client = new ApiClient(
  process.env.RECOMBEE_DATABASE_ID ?? '',
  process.env.RECOMBEE_DATABASE_PRIVATE_TOKEN ?? '',
  { region: 'us-west' }
);

async function main() {
  try {
    const users = await client.send(new requests.ListUsers({ count: 10 }));
    console.log('Users:', users);
  } catch (err) {
    console.error(err);
  }
}
main();