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

@hubcommerce/trendyol

v2.0.0

Published

Trendyol TR Marketplace API SDK

Readme

@hubcommerce/trendyol

Trendyol TR Marketplace Integration API SDK.

Yalnızca server-side kullanın. API key/secret tarayıcıda, mobil uygulamada veya public repo'da asla bulunmamalı.

  • Node >=20.10.0 · ESM-only ("type": "module") · sıfır runtime dependency
  • TrendyolResult<T> — throw yerine ok / error
  • ~77 documented REST metodu + batch poll, stream, webhook inbound

Detay: docs/CONFORMANCE.md · docs/QA.md · docs/MIGRATION.md


Kurulum

npm install @hubcommerce/trendyol

Monorepo yerel:

npm install file:../commerce-packages/marketplace/trendyol

Yapılandırma

.env.example dosyasını kopyalayın:

copy marketplace\trendyol\.env.example .env

| Değişken | Açıklama | |----------|----------| | TRENDYOL_ENV | stage veya production | | TRENDYOL_SELLER_ID | Satıcı ID | | TRENDYOL_API_KEY | API key | | TRENDYOL_API_SECRET | API secret | | TRENDYOL_INTEGRATOR_NAME | Varsayılan SelfIntegration | | TRENDYOL_STORE_FRONT_CODE | Varsayılan TR |

Gateway URL matrisi

| Ortam | Gateway | |-------|---------| | Production | https://apigw.trendyol.com | | Stage | https://stageapigw.trendyol.com |

Eski api.trendyol.com/sapigw kullanılmaz.

Stage IP whitelist gerekir — değişiklik ~24 saat gecikebilir (QA.md).


Hızlı başlangıç

import { createTrendyolClient } from "@hubcommerce/trendyol";

const client = createTrendyolClient({
  sellerId: process.env.TRENDYOL_SELLER_ID!,
  apiKey: process.env.TRENDYOL_API_KEY!,
  apiSecret: process.env.TRENDYOL_API_SECRET!,
  env: "stage",
});

const conn = await client.testConnection();
if (!conn.ok) {
  console.error(conn.error.message);
}

Modül örnekleri

Sipariş stream (birincil senkron)

Trendyol önerisi: webhook + periyodik stream/poll birlikte kullanın.

import { createTrendyolClient } from "@hubcommerce/trendyol";

const client = createTrendyolClient();

for await (const page of client.orders.streamPackages({
  lookbackMs: 300_000, // varsayılan 5 dk — saat kayması için
  size: 50,
  onCursorSave: (cursor) => {
    // adapter: cursor'u DB'ye persist et
  },
})) {
  for (const pkg of page.content ?? []) {
    console.log(pkg.id, pkg.status);
  }
}

Stok / fiyat

const result = await client.inventory.updatePriceAndInventory([
  { barcode: "8683772071724", quantity: 10, salePrice: 99.9, listPrice: 129.9 },
]);

// quantity: 0 → satış durabilir (JSDoc uyarısı)

// Yalnızca stok (fiyat Trendyol'da olduğu gibi kalır)
await client.inventory.updatePriceAndInventory([{ barcode: "8683772071724", quantity: 4 }]);

Ürün oluşturma + batch poll

import { validateEan13 } from "@hubcommerce/trendyol";

if (!validateEan13("8683772071724")) throw new Error("Geçersiz barkod");

const submit = await client.products.createProducts([/* ProductCreateItem[] */]);
if (!submit.ok) throw submit.error;

const batch = await client.batch.waitForResult(submit.data.batchRequestId, {
  intervalMs: 2000,
  timeoutMs: 120_000,
});

if (batch.ok && batch.data.failedItemCount > 0) {
  // partial fail — adapter başarısız barkodları işler
  console.log(batch.data.items?.filter((i) => i.status === "FAILED"));
}

Webhook inbound

import {
  parseWebhookPayload,
  verifyWebhookApiKey,
} from "@hubcommerce/trendyol";

// HTTP handler (adapter katmanında)
if (!verifyWebhookApiKey(req.headers, process.env.WEBHOOK_API_KEY!)) {
  return res.status(401).end();
}

const parsed = parseWebhookPayload(req.body);
if (!parsed.ok) {
  return res.status(400).json({ error: parsed.error });
}

// adapter: dedup + iş kuyruğu
const pkg = parsed.data;

Fatura

// Invoiced statü ≠ fatura gönderimi — iki ayrı adım
await client.orders.updatePackageStatus(packageId, { status: "Invoiced", lines: [...] });

await client.invoices.sendInvoiceLink({
  shipmentPackageId: packageId,
  invoiceLink: "https://...",
  invoiceNumber: "INV-2026-001",
});

Finans

const orders = await client.finance.getPaymentOrders({ size: 10 });
if (orders.ok && orders.data.content?.[0]) {
  const paymentOrderId = orders.data.content[0].paymentOrderId;
  const details = await client.finance.getSettlementDetails(paymentOrderId);
}

Ortak etiket (TEX / Aras, Trendyol öder)

import { isCommonLabelNotAllowed } from "@hubcommerce/trendyol";

const created = await client.labels.createCommonLabel(cargoTrackingNumber);
if (!created.ok && isCommonLabelNotAllowed(created)) {
  // capability yok — alternatif kargo akışı
}

const label = await client.labels.getCommonLabel(cargoTrackingNumber);

// AB ihracat varyantı
await client.labels.getCommonLabelWithAbProduct(cargoTrackingNumber, {
  productLabelType: "ZPL",
});

Stage test helpers

import { createTestOrder, SHIPMENT_PACKAGE_FIXTURE } from "@hubcommerce/trendyol/testing";

Yalnızca stage — production config ile runtime guard throw eder.


Geliştirme

npm run build --workspace=@hubcommerce/trendyol
npm test --workspace=@hubcommerce/trendyol
npm run test:exports --workspace=@hubcommerce/trendyol
npm run qa:smoke --workspace=@hubcommerce/trendyol

Public API yüzeyi

Facade client domain modülleri:

| Modül | Açıklama | |-------|----------| | client.orders | Stream, mutasyon, split | | client.invoices | Link, dosya, silme | | client.inventory | Fiyat/stok toplu | | client.reference | Marka, kategori, adres, geo | | client.products | V2 CRUD, filter, buybox | | client.batch | waitForResult poll | | client.video | Video upload + poll | | client.warranty | Garanti belgesi | | client.claims | İade | | client.webhooks | CRUD | | client.finance | Hakedis, settlements | | client.qna | Müşteri soruları | | client.labels | Ortak etiket ZPL | | client.compensation | TEX tazmin | | client.testConnection() | Canonical bağlantı testi |

Root export helper'lar: parseWebhookPayload, verifyWebhookApiKey, validateEan13, buildProductCreatePayload, statik sabitler (CLAIM_REASONS, ORIGIN_COUNTRIES, …).


Migration

  • Ürün V1 kapanış: 15 Eylül 2026
  • Sipariş V1 kapanış: 15 Ekim 2026

Detay: docs/MIGRATION.md


Lisans

MIT — LICENSE