tradera-soap-api-client
v1.5.1
Published
Tradera API Client with typescript support
Readme
Tradera SOAP API Client
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-clientor if you use yarn
yarn add tradera-soap-api-clientUsage
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
| 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
| 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 buildCompiles TypeScript to JavaScript in the dist/ folder.
Regenerate Client
npm run generate-clientRegenerates the TypeScript client from Tradera's WSDL definitions. This fetches the latest WSDL from:
http://api.tradera.com/v3/SearchService.asmx?WSDLhttp://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:
TraderaRestrictedClient- For managing items, transactions, and shop settingsTraderaOrderClient- For managing orders
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 tokenTree 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
