Skip to content

SebbeJohansson/tradera-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tradera SOAP API Client

Version Downloads License

A fully-typed TypeScript client for the Tradera SOAP API. This package provides easy-to-use clients for Tradera's services, with auto-generated TypeScript types and client bindings.

Features

  • đź”’ Fully typed - Complete TypeScript definitions for all API methods and responses
  • ⚡ Async/await support - All API methods return Promises
  • 🛠️ IntelliSense support - Full autocomplete in VS Code and other TypeScript-aware editors
  • 🌳 Tree-shakeable - Import only what you need
  • 🔄 Auto-generated - Client code is generated directly from Tradera's WSDL definitions

Official Tradera API Documentation

Installation

npm install tradera-soap-api-client

or if you use yarn

yarn add tradera-soap-api-client

Usage

Search Service

Use TraderaSearchClient for searching items on Tradera:

import { TraderaSearchClient } from 'tradera-soap-api-client';

const searchClient = new TraderaSearchClient({
  appId: YOUR_APP_ID,
  appKey: "YOUR_APP_KEY"
});

// Basic search
const result = await searchClient.search({
  query: "vintage",
  categoryId: 0
});

console.log(result.SearchResult?.Items);
console.log(result.SearchResult?.TotalNumberOfItems);

// Advanced search with filters
const advancedResult = await searchClient.searchAdvanced({
  query: "retro",
  categoryId: 0,
  pageNumber: 1,
  itemsPerPage: 50,
  orderBy: "EndDateAscending"
});

// Search by zip code
const localResult = await searchClient.searchByZipCode({
  zipCode: "11122",
  distance: 10,
  categoryId: 0
});

Public Service

Use TraderaPublicClient for accessing item details, user information, categories, and more:

import { TraderaPublicClient } from 'tradera-soap-api-client';

const publicClient = new TraderaPublicClient({
  appId: YOUR_APP_ID,
  appKey: "YOUR_APP_KEY"
});

// Get item details
const item = await publicClient.getItem({ itemId: 123456789 });
console.log(item.GetItemResult?.Title);
console.log(item.GetItemResult?.CurrentBid);

// Get all categories
const categories = await publicClient.getCategories({});
console.log(categories.GetCategoriesResult?.Categories);

// Get user information
const user = await publicClient.getUserByAlias({ alias: "username" });
console.log(user.GetUserByAliasResult?.TotalRating);

// Get seller's items
const sellerItems = await publicClient.getSellerItems({ sellerId: 12345 });
console.log(sellerItems.GetSellerItemsResult?.Items);

// Get user feedback
const feedback = await publicClient.getFeedback({ userId: 12345 });
console.log(feedback.GetFeedbackResult?.Feedbacks);

// Get official Tradera time (for auction endings)
const time = await publicClient.getOfficalTime({});
console.log(time.GetOfficalTimeResult);

Using the Raw SOAP Client

For more control, you can use the generated SOAP client directly:

import { createClientAsync } from './src/generated/search/client.js';

async function searchTradera() {
  const wsdlUrl = "http://api.tradera.com/v3/SearchService.asmx?WSDL";
  const client = await createClientAsync(wsdlUrl);

  // Add required Tradera authentication headers
  client.addSoapHeader({
    AuthenticationHeader: {
      AppId: YOUR_APP_ID,
      AppKey: "YOUR_APP_KEY"
    }
  }, '', 'tns', 'http://api.tradera.com');

  // Search for items
  const result = await client.SearchAsync({
    query: "vintage",
    categoryId: 0
  });

  console.log(result.SearchResult?.Items);
  console.log(result.SearchResult?.TotalNumberOfItems);
}

Available API Methods

Search Service

Official Documentation

Method Description Documentation
search Search for items Search
searchAdvanced Advanced search with filters SearchAdvanced
searchCategoryCount Get category counts for search SearchCategoryCount
searchByFixedCriteria Search with fixed criteria lists SearchByFixedCriteria
searchByZipCode Search items near a zip code SearchByZipCode

Public Service

Official Documentation

Method Description Documentation
getItem Get details for a specific item GetItem
getSellerItems Get items from a specific seller GetSellerItems
getSellerItemsQuickInfo Get minimal item info (useful for new items) GetSellerItemsQuickInfo
getUserByAlias Get user information by alias GetUserByAlias
fetchToken Fetch authorization token FetchToken
getOfficalTime Get official Tradera time GetOfficalTime
getCategories Get category hierarchy GetCategories
getAttributeDefinitions Get attribute definitions for a category GetAttributeDefinitions
getAcceptedBidderTypes Get accepted bidder types GetAcceptedBidderTypes
getExpoItemTypes Get expo item types with prices GetExpoItemTypes
getItemTypes Get available item types GetItemTypes
getCounties Get list of counties for search GetCounties
getItemFieldValues Get available item field values GetItemFieldValues
getItemAddedDescriptions Get added descriptions for an item GetItemAddedDescriptions
getFeedback Get user feedback GetFeedback
getFeedbackSummary Get user feedback summary GetFeedbackSummary
getShippingOptions Get shipping options for countries GetShippingOptions

Deprecated Methods

Method Description Use Instead
getSearchResult Search for items TraderaSearchClient.search
getSearchResultAdvanced Advanced search TraderaSearchClient.searchAdvanced
getSearchResultAdvancedXml XML-based search TraderaSearchClient.searchAdvanced
getPaymentTypes Get payment types getItemFieldValues
getShippingTypes Get shipping types getItemFieldValues

Scripts

Build

npm run build

Compiles TypeScript to JavaScript in the dist/ folder.

Regenerate Client

npm run generate-client

Regenerates the TypeScript client from Tradera's WSDL definitions. This fetches the latest WSDL from:

  • http://api.tradera.com/v3/SearchService.asmx?WSDL
  • http://api.tradera.com/v3/PublicService.asmx?WSDL

Authentication

To use the Tradera API, you need to register for API credentials at Tradera's developer portal. You will receive:

  • AppId - Your application ID (number)
  • AppKey - Your application key (GUID string)

These are automatically included in SOAP headers when using the wrapper clients.

User Impersonation

Some services require user impersonation in addition to app credentials. This means you need to provide the Tradera user's ID and authorization token:

const client = new TraderaRestrictedClient({
  appId: YOUR_APP_ID,
  appKey: "YOUR_APP_KEY",
  userId: 12345,          // Tradera user ID
  token: "USER_TOKEN"     // Authorization token
});

To obtain a user token, use the fetchToken method from TraderaPublicClient:

import { TraderaPublicClient } from 'tradera-soap-api-client';

const publicClient = new TraderaPublicClient({
  appId: YOUR_APP_ID,
  appKey: "YOUR_APP_KEY"
});

const tokenResponse = await publicClient.fetchToken({
  userName: "trader-username",
  password: "trader-password"
});

console.log(tokenResponse.FetchTokenResult); // The auth token

Tree Shaking

This package supports tree shaking. You can import only what you need:

// Import only the search client
import { TraderaSearchClient } from 'tradera-soap-api-client';

// Or import types directly from subpaths
import { Search } from 'tradera-soap-api-client/search';
import { Public } from 'tradera-soap-api-client/public';

Dependencies

  • soap - SOAP client for Node.js
  • wsdl-tsclient - TypeScript client generator from WSDL

License

MIT

About

Node js module for the tradera soap api

Resources

License

Stars

Watchers

Forks

Packages

No packages published