Skip to content

About

Official Node.js and TypeScript SDK for the ZalTrack Zalando price tracking API.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ZalTrack Node.js SDK

The official Node.js and TypeScript SDK for the ZalTrack Zalando price tracking API.

Track Zalando prices and products with a scheduled watchlist, price history and alerts.

The SDK exposes 9 typed methods, one per documented endpoint, plus a generic request() for anything else.

Requirements

  • Node.js 20 or newer

Installation

npm install @zaltrack/sdk

The SDK works with TypeScript and JavaScript (ES modules). The examples below use TypeScript; JavaScript users can use the same API by omitting TypeScript-only syntax.

Get your API key

Sign up for ZalTrack or sign in to your existing account, then copy your API key from the dashboard. Store it securely, for example in the ZALTRACK_API_KEY environment variable, which the client reads by default.

Quick start

import { ZalTrackClient } from "@zaltrack/sdk";

const client = new ZalTrackClient({ apiKey: process.env.ZALTRACK_API_KEY });

const response = await client.searchZalando({ query: "nike trainers" });
console.log(response.data);

Every method takes a parameter object that mirrors the API reference (snake_case names, exactly as documented) and an optional RequestOptions object.

HTTP methods

Each method uses the HTTP verb of its endpoint. GET and DELETE send parameters in the query string; POST and PATCH send them as a JSON body, except wait on /products/{id}/check, which stays in the query string. A null in a JSON body is sent: updateProduct({ id, target_price: null }), or clearTargetPrice(id), removes the target price.

undefined is omitted, null and empty arrays are left out of the query string, false and 0 are sent, and arrays repeat the parameter name (a=1&a=2).

Any endpoint

request() reaches any path, including endpoints released after this SDK version:

const response = await client.request("GET", "/account");

Responses

  • JsonResponse — kind: "json", the parsed body in data (pass a type argument to type it: client.searchZalando<MyType>(…)).
  • BinaryResponse — kind: "binary", the body in bytes and its contentType.

Both keep the buffered rawResponse (status, headers, content type, body bytes).

Errors

import { ZalTrackApiError } from "@zaltrack/sdk";

try {
  await client.searchZalando({ query: "nike trainers" });
} catch (error) {
  if (error instanceof ZalTrackApiError) {
    console.error(error.status, error.message, error.responseBody);
  }
  throw error;
}
Error When
ZalTrackConfigurationError Missing API key, invalid options or unsupported method.
ZalTrackSerializationError A required parameter is missing or a value can't be sent.
ZalTrackTransportError Network failure or client-side timeout.
ZalTrackApiError The API answered with a non-2xx status (status, errorCode, message, responseBody).
ZalTrackResponseDecodingError A success response could not be decoded.

All of them extend ZalTrackError. Common statuses: 400 invalid parameters, 401 invalid API key, 402 no credits left, 429 rate limit exceeded.

Retries

Requests are retried up to 3 times after a network error, a 408, 500, 502, 503 or 504. Other statuses, such as 400, 401, 402, 404 or 429, and client-side timeouts are not retried: the API's rate limits last until the hour (or the day) is over, and on the free plan every retry would count as a request. The delay starts at 1 second and grows 1.5× per retry (capped at 30 seconds); a Retry-After header wins.

const client = new ZalTrackClient({ maxRetries: 5, retryDelay: 500 });

// or for one request
await client.searchZalando({ query: "nike trainers" }, { maxRetries: 0 });

Batch requests

batch() runs a task per item with at most 10 in flight (concurrency), and returns one result per item in input order, shaped like Promise.allSettled. One failure never stops the others.

const inputs = ["nike trainers", "rain jacket", "leather boots"];
const results = await client.batch(
  inputs,
  (query) => client.searchZalando({ query }),
  { concurrency: 5 },
);

for (const result of results) {
  if (result.status === "fulfilled") console.log(result.value.data);
  else console.error(inputs[result.index], result.reason);
}
Constant Default Description
DEFAULT_CONCURRENCY 10 Tasks run at the same time by batch
DEFAULT_TIMEOUT_MS 120000 Request timeout (milliseconds)
MAX_RETRIES 3 Retry attempts after a network error, a 408/5xx
RETRY_BACKOFF_FACTOR 1.5 Exponential backoff multiplier
DEFAULT_RETRY_DELAY_MS 1000 Delay before the first retry (milliseconds)

Timeouts and cancellation

const client = new ZalTrackClient({ timeout: 60_000 }); // default 120000 ms, 0 disables

await client.searchZalando(
  { query: "nike trainers" },
  {
    signal: AbortSignal.timeout(30_000),
  },
);

Advanced: custom Fetch transport

import { ZalTrackClient, type ZalTrackFetch } from "@zaltrack/sdk";

const loggingFetch: ZalTrackFetch = async (input, init) => {
  const response = await fetch(input, init);
  console.log(init.method, String(input), response.status);
  return response;
};

const client = new ZalTrackClient({ fetch: loggingFetch });

Endpoints

9 methods, generated from the OpenAPI document.

Method HTTP Description
checkProduct() POST /products/{id}/check Asks for a check right away (1 credit), at most once per 5 minutes; earlier calls return the product unchanged. A paused product has to be…
deleteProduct() DELETE /products/{id} Removes the product and its price history.
getAccount() GET /account Your plan, the credits left (monthly allowance and packs), how many products you track and the credits they use per month, the credits each…
getArticleHistory() GET /history Every price ZalTrack read for an article reference on a marketplace over the period, whoever tracks it, oldest first, with the lowest, high…
getProduct() GET /products/{id} The product's latest state and every price read of the period, oldest first. The history covers every read of this article reference on thi…
listProducts() GET /products Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with article_id (and marketplace) to k…
searchZalando() GET /search Zalando search results (sponsored included), to find the article reference of a product. Free, limited to 30 searches per hour.
trackProduct() POST /products Adds an article reference or a Zalando link to your watchlist. The first check runs in the background within seconds (checking is true unti…
updateProduct() PATCH /products/{id} Target price, drop alerts, check interval, or pause. Send only what changes. On the free plan, alerts (price drop, back in stock, target pr…

All ZalTrack SDKs

SDK Package Install
Node.js @zaltrack/sdk npm install @zaltrack/sdk
Python zaltrack pip install zaltrack
Go zaltrack-go go get github.com/zaltrackdev/zaltrack-go
.NET ZalTrack dotnet add package ZalTrack
Ruby zaltrack gem install zaltrack
PHP zaltrack/sdk composer require zaltrack/sdk
Java zaltrack-java build from source, see its README
CLI @zaltrack/cli npm install -g @zaltrack/cli
MCP server @zaltrack/mcp npx -y @zaltrack/mcp

Trademarks

ZALANDO® is a registered trademark of Zalando SE. ZalTrack is not affiliated with, endorsed or sponsored by Zalando.

License

MIT — see LICENSE.

About

Official Node.js and TypeScript SDK for the ZalTrack Zalando price tracking API.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages