Skip to content
asindotdevPublic

About

Official Node.js and TypeScript SDK for the Asin Amazon price tracking API.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Asin Node.js SDK

The official Node.js and TypeScript SDK for the Asin Amazon price tracking API.

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

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

Requirements

  • Node.js 20 or newer

Installation

npm install @asindev/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 Asin or sign in to your existing account, then copy your API key from the dashboard. Store it securely, for example in the ASIN_API_KEY environment variable, which the client reads by default.

Quick start

import { AsinClient } from "@asindev/sdk";

const client = new AsinClient({ apiKey: process.env.ASIN_API_KEY });

const response = await client.searchAmazon({ query: "wireless earbuds" });
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. Null values are never sent, so target_price cannot be removed through the SDK yet.

null, undefined and empty arrays are omitted, 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.searchAmazon<MyType>(…)).
  • BinaryResponse — kind: "binary", the body in bytes and its contentType.

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

Errors

import { AsinApiError } from "@asindev/sdk";

try {
  await client.searchAmazon({ query: "wireless earbuds" });
} catch (error) {
  if (error instanceof AsinApiError) {
    console.error(error.status, error.message, error.responseBody);
  }
  throw error;
}
Error When
AsinConfigurationError Missing API key, invalid options or unsupported method.
AsinSerializationError A required parameter is missing or a value can't be sent.
AsinTransportError Network failure or client-side timeout.
AsinApiError The API answered with a non-2xx status (status, message, responseBody).
AsinResponseDecodingError A success response could not be decoded.

All of them extend AsinError. 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, 429, 500, 502, 503 or 504. Other statuses, such as 400, 401, 402 or 404, and client-side timeouts are not retried. The delay starts at 1 second and grows 1.5× per retry (capped at 30 seconds); a Retry-After header wins.

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

// or for one request
await client.searchAmazon({ query: "wireless earbuds" }, { 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 = ["wireless earbuds", "mechanical keyboard", "usb-c hub"];
const results = await client.batch(
  inputs,
  (query) => client.searchAmazon({ 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/429/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 AsinClient({ timeout: 60_000 }); // default 120000 ms, 0 disables

await client.searchAmazon(
  { query: "wireless earbuds" },
  {
    signal: AbortSignal.timeout(30_000),
  },
);

Advanced: custom Fetch transport

import { AsinClient, type AsinFetch } from "@asindev/sdk";

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

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

Endpoints

11 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.
fetchOffers() POST /offers Reads the offers on Amazon for 1 credit, refunded if it doesn't answer. A read made in the last 3 hours, by anyone, is returned instead, fo…
getAccount() GET /account Your plan, the credits left (monthly allowance and packs), how many products you track and the credits they use per month.
getAsinHistory() GET /history Every price Asin read for an ASIN on a marketplace over the period, whoever tracks it, oldest first, with the lowest, highest and average o…
getOffers() GET /offers Who sells the product and at what price, as last read, cheapest first, with Amazon's own price and the cheapest new and used offers (used i…
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 ASIN on this marketplace…
listProducts() GET /products Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with asin (and marketplace) to know if…
searchAmazon() GET /search Amazon search results (up to 60, sponsored included), to find the ASIN of a product. Free, limited to 30 searches per hour.
trackProduct() POST /products Adds an ASIN, an Amazon link or a short link (amzn.to, a.co…) to your watchlist. The first check runs in the background within seconds (che…
updateProduct() PATCH /products/{id} Target price, drop alerts, check interval, or pause. Send only what changes.

All Asin SDKs

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

License

MIT — see LICENSE.

About

Official Node.js and TypeScript SDK for the Asin Amazon price tracking API.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages