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

@tradebuddyhq/ebay-wrapper

v2.0.0

Published

Comprehensive, fully-typed eBay REST API wrapper for Node.js — Browse, Order, Inventory, Fulfillment, Account, Marketing, Finances, Taxonomy & more

Downloads

98

Readme

@tradebuddyhq/ebay-wrapper

CI npm version License: MIT TypeScript Node.js

Comprehensive, fully-typed TypeScript wrapper for the eBay REST APIs. Zero runtime dependencies — uses native fetch.

Features

  • 13 API modules — Browse, Order, Marketplace Insights, Inventory, Fulfillment, Account, Marketing, Finances, Taxonomy, Catalog, Developer Analytics
  • 100+ typed endpoints with full request/response types
  • OAuth 2.0 — Client Credentials (app tokens) + Authorization Code Grant (user tokens)
  • Automatic token caching with refresh-ahead
  • Rate limiting — configurable token-bucket limiter
  • Retry with exponential backoff — automatic retry on 429/5xx with jitter
  • Auto-pagination — async iterators for paginated endpoints
  • Sandbox support — toggle between production and sandbox environments
  • Zero dependencies — uses native fetch (Node.js 18+)

Install

npm install @tradebuddyhq/ebay-wrapper

Quick Start

import { Client } from "@tradebuddyhq/ebay-wrapper";

const client = new Client({
  clientId: process.env.EBAY_CLIENT_ID!,
  clientSecret: process.env.EBAY_CLIENT_SECRET!,
  marketplaceId: "EBAY_US",
});

// Search for items
const results = await client.buy.browse.search({
  q: "mechanical keyboard",
  limit: 5,
});

for (const item of results.itemSummaries ?? []) {
  console.log(`${item.title} — ${item.price?.value} ${item.price?.currency}`);
}

Configuration

const client = new Client({
  // Required
  clientId: "your-client-id",
  clientSecret: "your-client-secret",

  // Optional
  env: "production",        // "production" | "sandbox"
  marketplaceId: "EBAY_US", // eBay marketplace header
  acceptLanguage: "en-US",  // Accept-Language header
  timeoutMs: 15000,         // Request timeout (ms)
  maxRetries: 3,            // Retry attempts on 429/5xx
  rateLimitPerSecond: 5,    // Requests per second limit
  userAgent: "MyApp/1.0",   // Custom User-Agent

  // For user-level APIs (Sell APIs)
  refreshToken: "...",      // User OAuth refresh token
  accessToken: "...",       // Or supply a token directly
});

API Reference

Buy APIs

// Browse — search and view items
client.buy.browse.search(params)
client.buy.browse.getItem(itemId)
client.buy.browse.getItemByLegacyId(legacyItemId, options?)
client.buy.browse.getItems(itemIds)
client.buy.browse.getItemsByItemGroup(itemGroupId)
client.buy.browse.checkCompatibility(itemId, payload)

// Order — guest checkout
client.buy.order.initiateGuestCheckoutSession(request)
client.buy.order.getGuestCheckoutSession(sessionId)
client.buy.order.updateGuestQuantity(sessionId, request)
client.buy.order.updateGuestShippingAddress(sessionId, request)
client.buy.order.updateGuestPayment(sessionId, request)
client.buy.order.placeGuestOrder(sessionId)
client.buy.order.getGuestPurchaseOrder(orderId)

// Marketplace Insights — sold item analytics
client.buy.marketplaceInsights.search(params)

Sell APIs

Sell APIs require user-level OAuth. Pass a refreshToken in the client config.

// Inventory — manage listings
client.sell.inventory.createOrReplaceInventoryItem(sku, item)
client.sell.inventory.getInventoryItem(sku)
client.sell.inventory.getInventoryItems(params?)
client.sell.inventory.deleteInventoryItem(sku)
client.sell.inventory.bulkCreateOrReplaceInventoryItem(request)
client.sell.inventory.bulkUpdatePriceQuantity(request)
client.sell.inventory.createOffer(offer)
client.sell.inventory.getOffer(offerId)
client.sell.inventory.getOffers(params?)
client.sell.inventory.updateOffer(offerId, offer)
client.sell.inventory.deleteOffer(offerId)
client.sell.inventory.publishOffer(offerId)
client.sell.inventory.withdrawOffer(offerId)
client.sell.inventory.publishOfferByInventoryItemGroup(key)
client.sell.inventory.withdrawOfferByInventoryItemGroup(key)
client.sell.inventory.createOrReplaceInventoryItemGroup(key, group)
client.sell.inventory.getInventoryItemGroup(key)
client.sell.inventory.deleteInventoryItemGroup(key)
client.sell.inventory.bulkMigrateListing(request)

// Fulfillment — orders and shipping
client.sell.fulfillment.getOrders(params?)
client.sell.fulfillment.getOrder(orderId)
client.sell.fulfillment.getShippingFulfillments(orderId)
client.sell.fulfillment.getShippingFulfillment(orderId, fulfillmentId)
client.sell.fulfillment.createShippingFulfillment(orderId, request)
client.sell.fulfillment.issueRefund(orderId, request)

// Account — seller policies
client.sell.account.getPrivileges()
client.sell.account.getOptedInPrograms()
client.sell.account.optInToProgram(programType)
client.sell.account.optOutOfProgram(programType)
client.sell.account.getFulfillmentPolicies(marketplaceId)
client.sell.account.getFulfillmentPolicy(policyId)
client.sell.account.createFulfillmentPolicy(policy)
client.sell.account.updateFulfillmentPolicy(policyId, policy)
client.sell.account.deleteFulfillmentPolicy(policyId)
client.sell.account.getPaymentPolicies(marketplaceId)
client.sell.account.createPaymentPolicy(policy)
client.sell.account.updatePaymentPolicy(policyId, policy)
client.sell.account.deletePaymentPolicy(policyId)
client.sell.account.getReturnPolicies(marketplaceId)
client.sell.account.createReturnPolicy(policy)
client.sell.account.updateReturnPolicy(policyId, policy)
client.sell.account.deleteReturnPolicy(policyId)
client.sell.account.getSalesTaxes(countryCode)
client.sell.account.createOrReplaceSalesTax(countryCode, jurisdictionId, salesTax)
client.sell.account.deleteSalesTax(countryCode, jurisdictionId)

// Marketing — Promoted Listings & promotions
client.sell.marketing.getCampaigns(params?)
client.sell.marketing.getCampaign(campaignId)
client.sell.marketing.createCampaign(campaign)
client.sell.marketing.updateCampaign(campaignId, campaign)
client.sell.marketing.deleteCampaign(campaignId)
client.sell.marketing.pauseCampaign(campaignId)
client.sell.marketing.resumeCampaign(campaignId)
client.sell.marketing.endCampaign(campaignId)
client.sell.marketing.getAds(campaignId, params?)
client.sell.marketing.createAd(campaignId, request)
client.sell.marketing.bulkCreateAdsByListingId(campaignId, request)
client.sell.marketing.deleteAd(campaignId, adId)
client.sell.marketing.getPromotions(params?)
client.sell.marketing.createPromotion(promotion)
client.sell.marketing.updatePromotion(promotionId, promotion)
client.sell.marketing.deletePromotion(promotionId)

// Finances — payouts, transactions, transfers
client.sell.finances.getTransactions(params?)
client.sell.finances.getTransaction(transactionId)
client.sell.finances.getPayouts(params?)
client.sell.finances.getPayout(payoutId)
client.sell.finances.getPayoutSummary(filter?)
client.sell.finances.getTransfers(params?)
client.sell.finances.getTransfer(transferId)
client.sell.finances.getSellerFundsSummary()

Commerce APIs

// Taxonomy — category trees and aspects
client.commerce.taxonomy.getDefaultCategoryTreeId(marketplaceId)
client.commerce.taxonomy.getCategoryTree(categoryTreeId)
client.commerce.taxonomy.getCategorySubtree(categoryTreeId, categoryId)
client.commerce.taxonomy.getCategorySuggestions(categoryTreeId, query)
client.commerce.taxonomy.getItemAspectsForCategory(categoryTreeId, categoryId)
client.commerce.taxonomy.getCompatibilityProperties(categoryTreeId, categoryId)
client.commerce.taxonomy.getCompatibilityPropertyValues(categoryTreeId, categoryId, propertyName)

// Catalog — product search
client.commerce.catalog.search(params)
client.commerce.catalog.getProduct(epid)

Developer APIs

// Analytics — rate limit info
client.developer.analytics.getRateLimits(apiContext?, apiName?)

OAuth: User Authorization Flow

For Sell APIs, you need user-level tokens via the Authorization Code Grant:

const client = new Client({
  clientId: "your-client-id",
  clientSecret: "your-client-secret",
});

// 1. Generate the authorization URL
const authUrl = client.oauth.generateAuthUrl(
  "https://yourapp.com/callback",
  undefined, // default scopes for all Sell APIs
  "optional-state",
);
// Redirect the user to authUrl

// 2. Exchange the code (from the callback) for tokens
const tokens = await client.oauth.exchangeCodeForToken(
  "authorization-code-from-callback",
  "https://yourapp.com/callback",
);
// tokens.access_token, tokens.refresh_token

// 3. Use the refresh token in future client instances
const authedClient = new Client({
  clientId: "your-client-id",
  clientSecret: "your-client-secret",
  refreshToken: tokens.refresh_token,
});

const orders = await authedClient.sell.fulfillment.getOrders();

Pagination

Auto-paginate through results with async iterators:

import { paginate, paginateAll } from "@tradebuddyhq/ebay-wrapper";

// Iterate page by page
for await (const page of paginate(
  (p) => client.buy.browse.search(p),
  { q: "laptop", limit: 50 },
)) {
  console.log(page.itemSummaries?.length, "items");
}

// Or collect everything into one array
const allItems = await paginateAll(
  (p) => client.buy.browse.search(p),
  { q: "laptop", limit: 200 },
  (page) => page.itemSummaries,
);

Error Handling

import { EbayError, EbayRateLimitError, EbayAuthError, EbayTimeoutError } from "@tradebuddyhq/ebay-wrapper";

try {
  await client.buy.browse.getItem("invalid-id");
} catch (err) {
  if (err instanceof EbayRateLimitError) {
    console.log("Rate limited, retry after:", err.retryAfterMs, "ms");
  } else if (err instanceof EbayAuthError) {
    console.log("Authentication failed");
  } else if (err instanceof EbayTimeoutError) {
    console.log("Request timed out");
  } else if (err instanceof EbayError) {
    console.log("eBay error:", err.status, err.errorId, err.errors);
  }
}

Development

npm install
npm run build
npm test
npm run test:coverage

License

MIT