tradly
v1.1.99
Published
Tradly JS SDK
Readme
Tradly helps developers / non technical founders with low-code/no-code solution to launch marketplaces, Ecosystem for SaaS and commerce apps.
Features
- ✅ 100+ API Endpoints - Comprehensive coverage of all Tradly platform features
- ✅ Automatic Key Management - Integrates with
@tradly/authfor automatic key injection - ✅ Multi-Environment Support - Production, Development, Sandbox
- ✅ Domain-Based Configuration - Support for multiple domains
- ✅ Error Handling - Consistent error-first callback pattern
- ✅ TypeScript Ready - Works with TypeScript projects
Installation
npm install tradlyOptional: Install with Auth Package
For automatic key management, also install @tradly/auth:
npm install tradly @tradly/authQuick Start
Option 1: With @tradly/auth (Recommended)
Simplest approach - just initialize auth, then use tradly sdk directly:
import { initializeAuth, emailLogin } from "@tradly/auth";
import TradlySDK from "tradly";
// Step 1: Initialize auth (once at app start)
initializeAuth("beauty.tradly.co", "production");
// Step 2: Login via auth (keys automatically stored)
await emailLogin("[email protected]", "password");
// Step 3: Use tradly APIs directly (keys auto-injected!)
const [error, response] = await TradlySDK.app.getListings({
bodyParam: {},
// authKey automatically from auth package!
});Benefits:
- ✅ No need to call
init_v2.config() - ✅ Keys automatically injected
- ✅ Environment and base URL synced from auth
- ✅ Simplest usage
Option 2: Standalone (Without Auth Package)
import TradlySDK from "tradly";
// Initialize tradly
await TradlySDK.init_v2.config({
domain: "beauty.tradly.co",
env: "production",
});
// Use APIs with manual authKey
const [error, response] = await TradlySDK.app.getListings({
authKey: "your-auth-key",
bodyParam: {},
});Option 3: With Both (Explicit Control)
import { initializeAuth, emailLogin } from "@tradly/auth";
import TradlySDK from "tradly";
// Initialize auth
initializeAuth("beauty.tradly.co", "production");
await emailLogin("[email protected]", "password");
// Initialize tradly (uses auth's PK key automatically)
await TradlySDK.init_v2.config({
domain: "beauty.tradly.co",
env: "production",
});
// Use APIs (keys auto-injected)
const [error, response] = await TradlySDK.app.getListings({
bodyParam: {},
});Initialization
Using InitV2 (Recommended)
import TradlySDK from "tradly";
await TradlySDK.init_v2.config({
domain: "beauty.tradly.co", // Required
env: "production", // Required: "production" | "development" | "sandbox"
custom_header: {}, // Optional: Custom headers
is_skip_pk_by_domain: false, // Optional: Skip PK key fetch
});Note: If @tradly/auth is initialized, init_v2.config() will
automatically use auth's cached PK key (no duplicate API call).
Using Legacy Init (Deprecated)
import TradlySDK from "tradly";
await TradlySDK.init.config({
token: "your-pk-key", // PK key
environment: "production", // Environment
custom_header: {}, // Optional
});Integration with @tradly/auth
tradly automatically integrates with @tradly/auth when available:
Automatic Features
PK Key Auto-Injection:
- If
APPCONSTANT.TOKENis empty, gets PK key from auth's cache - Caches it for future use
- If
Auth Key Auto-Injection:
- If
authKeynot provided in method params, gets from auth package - Adds to
x-auth-keyheader automatically
- If
Environment Sync:
- Syncs environment from auth config if
APPCONSTANT.ENVIRONMENTis empty
- Syncs environment from auth config if
Base URL Sync:
- Uses auth's
baseUrlif available (preferred over tradly's Environment function)
- Uses auth's
Backward Compatibility
- ✅ Works without
@tradly/authpackage - ✅ Manual
authKeypassing still works - ✅ No breaking changes
API Methods
All methods return [error, response] format (error-first callback pattern).
Response Format
const [error, response] = await TradlySDK.app.getListings({});
if (error) {
// Handle error
console.error("Error:", error);
} else {
// Use response
console.log("Data:", response.data);
}API Reference
Configuration & Setup
| Method | Description | Parameters |
| ------------------- | ------------------------ | -------------------------------------------------------- |
| init_v2.config() | Initialize SDK (new way) | { domain, env, custom_header?, is_skip_pk_by_domain? } |
| init.config() | Initialize SDK (legacy) | { token, environment, custom_header? } |
| init.refreshAPI() | Refresh auth token | { refreshKey } |
User Management
| Method | Description | Parameters |
| ------------------------- | ------------------------ | ---------------------------------- |
| app.getUserDetail() | Get user by ID | { authKey, id } |
| app.getUserProfile() | Get current user profile | { authKey, id? } |
| app.getUsersList() | Get users list | { authKey, bodyParam? } |
| app.updateUserInfo() | Update user info | { authKey, id, data } |
| app.deleteUser() | Delete user | { authKey, id } |
| app.getUserAttributes() | Get user attributes | { authKey, id, recaptcha_token } |
| app.userFollow() | Follow a user | { authKey, data } |
| app.getUserFollowings() | Get user followings | { authKey, bodyParam? } |
| app.getUserFollowers() | Get user followers | { authKey, bodyParam? } |
Listings
| Method | Description | Parameters |
| --------------------------------- | ------------------------------- | ----------------------------- |
| app.getListings() | Get listings | { authKey?, bodyParam? } |
| app.getListingDetail() | Get listing detail | { authKey?, id, slug? } |
| app.postListing() | Create/Update listing | { authKey?, id?, data } |
| app.deleteListing() | Delete listing | { authKey?, id } |
| app.likeListing() | Like/Unlike listing | { authKey?, id, isLiked } |
| app.unlikeListing() | Unlike listing | { authKey?, id, isUnLiked } |
| app.bulkLikeListings() | Bulk like listings | { authKey?, data } |
| app.getMyListingsLikes() | Get my liked listings | { authKey?, bodyParam? } |
| app.reportListing() | Report listing | { authKey?, id, data } |
| app.getListingsLocations() | Get listings locations | { authKey?, bodyParam? } |
| app.FollowingAccountsListings() | Get following accounts listings | { authKey?, bodyParam? } |
Note: authKey is optional if @tradly/auth is initialized - it will be
auto-injected.
Listings - Pricing Rules
| Method | Description | Parameters |
| ----------------------------------- | -------------------------- | ----------------------------------------------- |
| app.postPricingRules() | Create/Update pricing rule | { authKey?, listing_id, rule_id?, data } |
| app.getListingsPricingRules() | Get pricing rules | { authKey?, listing_id, bodyParam? } |
| app.getListingSinglePricingRule() | Get single pricing rule | { authKey?, listing_id, rule_id, bodyParam? } |
| app.deleteListingPricingRule() | Delete pricing rule | { authKey?, listing_id, rule_id } |
Listings - Negotiations
| Method | Description | Parameters |
| -------------------------- | --------------------- | ---------------------------------------- |
| app.addNegotiation() | Add negotiation | { authKey?, id, data } |
| app.updateNegotiation() | Update negotiation | { authKey?, id, negotiation_id, data } |
| app.getNegotiationList() | Get negotiations list | { authKey?, id, bodyParam? } |
Listings - Schedules
| Method | Description | Parameters |
| ---------------------- | --------------- | ------------------------------ |
| app.createSchedule() | Create schedule | { authKey?, id, data } |
| app.getSchedule() | Get schedule | { authKey?, id, bodyParam? } |
Variants
| Method | Description | Parameters |
| -------------------------------- | --------------------- | ------------------------------------- |
| app.getVariants() | Get variants | { authKey? } |
| app.getListingVariants() | Get listing variants | { authKey?, listingId } |
| app.getListingVariantDetails() | Get variant details | { authKey?, listingId, variant_id } |
| app.addEditVariants() | Create/Update variant | { authKey?, listingId, id?, data } |
| app.deleteVariant() | Delete variant | { authKey?, listingId, id } |
Variant Types
| Method | Description | Parameters |
| ---------------------------------- | -------------------------------- | ---------------------------------- |
| app.getVariantTypes() | Get variant types | { authKey? } |
| app.addEditVariantsTypes() | Create/Update variant type | { authKey?, id?, data } |
| app.deleteVariantType() | Delete variant type | { authKey?, id } |
| app.getVariantTypeValues() | Get variant type values | { authKey?, id } |
| app.getVariantTypeValuesDetail() | Get variant type value detail | { authKey?, id, valueID } |
| app.addEditVariantTypeValues() | Create/Update variant type value | { authKey?, id, valueID?, data } |
| app.deleteVariantTypeValues() | Delete variant type value | { authKey?, id, valueID } |
Categories
| Method | Description | Parameters |
| ------------------------------- | ---------------------- | -------------------------------------- |
| app.getCategory() | Get categories | { authKey?, bodyParam? } |
| app.getSingleCategoryByID() | Get category by ID | { authKey?, categoryID, bodyParam? } |
| app.getSingleCategoryBySlug() | Get category by slug | { authKey?, slug, bodyParam? } |
| app.addEditCategory() | Create/Update category | { authKey?, id?, data } |
| app.deleteCategory() | Delete category | { authKey?, id } |
Attributes
| Method | Description | Parameters |
| -------------------------------- | ----------------------------- | ---------------------------------- |
| app.getAttribute() | Get attributes | { authKey?, bodyParam? } |
| app.getAttributesGrouped() | Get grouped attributes | { authKey?, bodyParam? } |
| app.getUserAttributeValues() | Get user attribute values | { authKey?, id, bodyParam? } |
| app.addEditAttribute() | Create/Update attribute | { authKey?, id?, data } |
| app.deleteAttribute() | Delete attribute | { authKey?, id } |
| app.getAttributeValues() | Get attribute values | { authKey?, id } |
| app.getAttributeValuesDetail() | Get attribute value detail | { authKey?, id, valueID } |
| app.addEditAttributeValues() | Create/Update attribute value | { authKey?, id, valueID?, data } |
| app.deleteAttributeValues() | Delete attribute value | { authKey?, id, valueID } |
Accounts
| Method | Description | Parameters |
| ------------------------------ | --------------------------- | ------------------------------- |
| app.getAccounts() | Get accounts | { authKey?, bodyParam? } |
| app.getAccountDetail() | Get account detail | { authKey?, id, slug? } |
| app.postAccounts() | Create/Update account | { authKey?, id?, data } |
| app.activeInactiveAccounts() | Activate/Deactivate account | { authKey?, id, data } |
| app.followUnfollowAccounts() | Follow/Unfollow account | { authKey?, id, isFollowing } |
| app.blockAccount() | Block/Unblock account | { authKey?, id, isBlocked } |
| app.reportAccount() | Report account | { authKey?, id, data } |
| app.getBlockAccounts() | Get blocked accounts | { authKey?, bodyParam? } |
| app.getFollowingAccounts() | Get following accounts | { authKey?, bodyParam? } |
| app.getAccountsLocations() | Get accounts locations | { authKey?, bodyParam? } |
Cart & Checkout
| Method | Description | Parameters |
| ----------------------------- | ------------------ | ------------------------------------- |
| app.getCarts() | Get cart | { authKey?, bodyParam?, currency? } |
| app.addToCart() | Add to cart | { authKey?, data } |
| app.deleteFromCart() | Remove from cart | { authKey?, data } |
| app.deleteAllCartDetail() | Clear cart | { authKey?, bodyParam? } |
| app.checkout() | Checkout from cart | { authKey?, data, currency? } |
| app.listingDirectCheckout() | Direct checkout | { authKey?, id, data, currency? } |
| app.applyCoupon() | Apply coupon | { authKey?, data } |
| app.removeCoupon() | Remove coupon | { authKey?, data } |
Orders
| Method | Description | Parameters |
| ---------------------------- | ---------------------- | -------------------------------------------------------- |
| app.getOrders() | Get orders | { authKey?, bodyParam? } |
| app.getOrderDetail() | Get order detail | { authKey?, id, bodyParam? } |
| app.updateOrderStatus() | Update order status | { authKey?, id, data, bodyParam? } |
| app.updateOrderDetail() | Update order details | { authKey?, id, data, bodyParam? } |
| app.updateOrderShipment() | Update order shipment | { authKey?, order_id, shipment_id, data, bodyParam? } |
| app.updateShipmentStatus() | Update shipment status | { authKey?, id, shipment_id, data, bodyParam? } |
| app.verifyOrderDetails() | Verify order details | { authKey?, data, bodyParam? } |
| app.confirmOrderByUser() | Confirm order | { authKey?, order_ref, access_key?, data, bodyParam? } |
| app.getOrderInvoice() | Get order invoice | { authKey?, order_id, bodyParam? } |
| app.getDonationsList() | Get donations list | { authKey?, listing_id, bodyParam? } |
Shipments
| Method | Description | Parameters |
| ------------------------------------ | ------------------------------ | ---------------------------------------------- |
| app.getSendCloudShipmentsMethods() | Get SendCloud shipping methods | { authKey?, bodyParam? } |
| app.getSendCloudShipmentLabel() | Get SendCloud shipping label | { authKey?, bodyParam? } |
| app.getExternalShipmentMethods() | Get external shipping methods | { authKey?, shipping_method_id, bodyParam? } |
| app.getExternalShipmentLabel() | Get external shipping label | { authKey?, order_id, shipment_id } |
Reviews
| Method | Description | Parameters |
| --------------------- | ----------- | -------------------------- |
| app.getReviewList() | Get reviews | { authKey?, bodyParam? } |
| app.addReview() | Add review | { authKey?, data } |
| app.likeReview() | Like review | { authKey?, id, data } |
Payments
| Method | Description | Parameters |
| --------------------------- | ------------------------- | ------------------------ |
| app.getPaymentMethods() | Get payment methods | { authKey? } |
| app.getEphemeralKey() | Get Stripe ephemeral key | { authKey?, id, data } |
| app.getPaymentIntentKey() | Get Stripe payment intent | { authKey?, id, data } |
MangoPay
| Method | Description | Parameters |
| ------------------------------------- | ------------------------- | -------------------------- |
| app.getKycDetails() | Get KYC details | { authKey?, id } |
| app.savePerSonalDetails() | Save personal details | { authKey?, data } |
| app.cardRegistration() | Register card | { authKey?, data } |
| app.confirmCardRegistration() | Confirm card registration | { authKey?, data } |
| app.PayINMangoPayCalc() | Calculate pay-in | { authKey?, data } |
| app.PayINMangoPayByCards() | Pay-in by cards | { authKey?, data } |
| app.PayINMangoPayPayPal() | Pay-in by PayPal | { authKey?, data } |
| app.PayINMangoPayByBank() | Pay-in by bank | { authKey?, data } |
| app.mangoPayWithdrawCalc() | Calculate withdrawal | { authKey?, data } |
| app.mangoPayWithdrawInit() | Initiate withdrawal | { authKey?, data } |
| app.mangoPayWithdrawConfirm() | Confirm withdrawal | { authKey?, data } |
| app.getMangopayWalletTransactions() | Get wallet transactions | { authKey?, bodyParam? } |
| app.getMangoPayWalletBalance() | Get wallet balance | { authKey?, bodyParam? } |
Stripe Connect
| Method | Description | Parameters |
| ------------------------------- | -------------------------- | -------------------- |
| app.getStripeConnectAccount() | Get Stripe Connect account | { authKey?, id } |
| app.createAccountLink() | Create account link | { authKey?, data } |
| app.createExpressLoginLink() | Create express login link | { authKey?, data } |
Saved Cards
| Method | Description | Parameters |
| ----------------------- | ----------------- | ----------------------- |
| app.getSavedCards() | Get saved cards | { authKey? } |
| app.deleteSavedCard() | Delete saved card | { authKey?, card_id } |
Addresses
| Method | Description | Parameters |
| ------------------------------- | ------------------------- | -------------------------- |
| app.getAddress() | Get addresses | { authKey?, bodyParam? } |
| app.addEditAddress() | Create/Update address | { authKey?, id?, data } |
| app.deleteAddress() | Delete address | { authKey?, id } |
| app.searchAddress() | Search address | { authKey?, searchKey } |
| app.reverseGeoCodingAddress() | Reverse geocoding | { authKey?, lat, long } |
| app.getPlacesAddress() | Get places address | { authKey?, bodyParam? } |
| app.getPlacesAddressDetails() | Get place address details | { authKey?, bodyParam? } |
| app.getStates() | Get states | { authKey?, bodyParam? } |
Shipping Methods
| Method | Description | Parameters |
| -------------------------- | -------------------- | ---------------------------------- |
| app.getShippingMethods() | Get shipping methods | { authKey?, type?, account_id? } |
Currency
| Method | Description | Parameters |
| ----------------------- | ---------------------- | ------------------------- |
| app.getCurrency() | Get currencies | { authKey? } |
| app.addEditCurrency() | Create/Update currency | { authKey?, id?, data } |
| app.deleteCurrency() | Delete currency | { authKey?, id } |
Collections
| Method | Description | Parameters |
| --------------------------- | ------------------------ | -------------------------- |
| app.getCollection() | Get collections | { authKey? } |
| app.getCollectionDetail() | Get collection detail | { authKey?, id } |
| app.addEditCollection() | Create/Update collection | { authKey?, id?, data } |
| app.deleteCollections() | Delete collection | { authKey?, id } |
| app.getCollectionData() | Get collection data | { authKey?, bodyParam? } |
Promo Banners
| Method | Description | Parameters |
| ------------------------- | -------------------------- | -------------------------- |
| app.getPromoBanner() | Get promo banners | { authKey?, bodyParam? } |
| app.addPromoBanner() | Create/Update promo banner | { authKey?, id?, data } |
| app.deletePromoBanner() | Delete promo banner | { authKey?, id } |
Transactions & Earnings
| Method | Description | Parameters |
| ----------------------- | ---------------- | -------------------------- |
| app.getTransactions() | Get transactions | { authKey?, bodyParam? } |
| app.getEarning() | Get earnings | { authKey?, bodyParam? } |
Commissions
| Method | Description | Parameters |
| --------------------------- | --------------------- | -------------------------- |
| app.getCommissions() | Get commissions | { authKey?, bodyParam? } |
| app.getCommissionDetail() | Get commission detail | { authKey?, id } |
Subscriptions
| Method | Description | Parameters |
| ------------------------------ | ------------------------- | ------------------------------------------- |
| app.subscribe() | Get subscriptions | { authKey?, bodyParam? } |
| app.productSubscription() | Get product subscriptions | { authKey?, bodyParam? } |
| app.subscriptionConfirm() | Confirm subscription | { authKey?, data } |
| app.manageSubscriptionLink() | Manage subscription link | { authKey?, data } |
| app.getSubscriptionList() | Get subscription listings | { authKey?, bodyParam? } |
| app.getSubscriptionDetails() | Get subscription details | { authKey?, listing_id } |
| app.subscribeByMangopay() | Subscribe via MangoPay | { authKey?, listing_id, data, currency? } |
Layers
| Method | Description | Parameters |
| ---------------------------- | ------------------- | -------------------------- |
| app.getLayer() | Get layers | { authKey?, bodyParam? } |
| app.getLayerDetail() | Get layer detail | { authKey?, id } |
| app.getLayerDetailBySlug() | Get layer by slug | { authKey?, id } |
| app.addEditLayer() | Create/Update layer | { authKey?, id?, data } |
| app.deleteLayer() | Delete layer | { authKey?, id } |
Taxes
| Method | Description | Parameters |
| ------------------------- | ----------------- | -------------------------- |
| app.getListingTaxes() | Get listing taxes | { authKey?, bodyParam? } |
| app.addEditListingTax() | Create/Update tax | { authKey?, id?, data } |
| app.deleteListingTax() | Delete tax | { authKey?, id } |
Translations
| Method | Description | Parameters |
| --------------------------------------- | ----------------------------- | -------------------------- |
| app.getTranslations() | Get translations | { authKey?, bodyParam? } |
| app.translateData() | Translate data | { authKey?, id, data } |
| app.getClientTranslationsGroups() | Get client translation groups | { authKey?, paramBody? } |
| app.getClientTranslationsValues() | Get client translation values | { authKey?, bodyParam? } |
| app.clientTranslationsValuesByGroup() | Get translations by group | { authKey?, bodyParam? } |
Feedback & Comments
| Method | Description | Parameters |
| ----------------------------- | ----------------------- | --------------------------------------- |
| app.getFeedbackCategories() | Get feedback categories | { authKey?, bodyParam? } |
| app.createFeedback() | Create feedback | { authKey?, data } |
| app.getComments() | Get comments | { authKey?, bodyParam? } |
| app.addEditComments() | Create/Update comment | { authKey?, id?, data } |
| app.likeUnlikeComments() | Like/Unlike comment | { authKey?, id, isLike, isDowngrade } |
Activities
| Method | Description | Parameters |
| --------------------- | -------------- | -------------------------- |
| app.getActivities() | Get activities | { authKey?, bodyParam? } |
Languages & Countries
| Method | Description | Parameters |
| -------------------------- | -------------------- | -------------- |
| app.getLanguages() | Get languages | { authKey? } |
| app.getTenantLanguages() | Get tenant languages | { authKey? } |
| app.getCountries() | Get countries | {} |
| app.getTenantCountries() | Get tenant countries | { authKey? } |
Configuration
| Method | Description | Parameters |
| ---------------------------------- | ------------------------- | -------------------------------------------------- |
| app.getConfigList() | Get config list | { authKey?, paramBody, domain_id? } |
| app.getGroupedConfigList() | Get grouped config list | { authKey?, paramBody, domain_id? } |
| app.getGroupedSecureConfigList() | Get grouped secure config | { authKey?, paramBody, domain_id?, access_key? } |
| app.home() | Get home data | { authKey? } |
S3 & Media
| Method | Description | Parameters |
| -------------------------- | ---------------------- | -------------------------------- |
| app.generateS3ImageURL() | Generate S3 signed URL | { authKey?, data } |
| app.uploadS3Image() | Upload image to S3 | { signedUrl, mime, blob_body } |
| app.getS3SignedURL() | Get S3 signed URL | { authKey?, data } |
Digital Content
| Method | Description | Parameters |
| --------------------------------- | ----------------------------- | --------------------------------------------- |
| app.getDigitalContents() | Get digital contents | { authKey?, listing_id, bodyParam? } |
| app.postAndEditDigitalContent() | Create/Update digital content | { authKey?, listing_id, content_id?, data } |
| app.deleteDigitalContent() | Delete digital content | { authKey?, listing_id, content_id } |
SSO
| Method | Description | Parameters |
| ---------------------- | ----------------- | ------------------------------- |
| app.postSsoReturn() | SSO return | { authKey?, data, currency? } |
| app.postSsoEnabled() | Check SSO enabled | { authKey?, data, currency? } |
Wallet
| Method | Description | Parameters |
| ----------------------------- | ----------------------- | -------------------------- |
| app.getWalletBalance() | Get wallet balance | { authKey? } |
| app.getWalletTransactions() | Get wallet transactions | { authKey?, bodyParam? } |
OPP Merchant
| Method | Description | Parameters |
| -------------------------- | -------------------- | -------------------------- |
| app.getMerchantDetails() | Get merchant details | { authKey?, bodyParam? } |
| app.createNewMerchant() | Create merchant | { authKey?, data } |
Time Slots
| Method | Description | Parameters |
| -------------------- | -------------- | -------------------------- |
| app.getTimeSlots() | Get time slots | { authKey?, bodyParam? } |
AI Services
| Method | Description | Parameters |
| --------------------------- | ---------------------- | ------------------------------- |
| app.getAiPromptResponse() | Get AI prompt response | { authKey?, data, currency? } |
Device Management
| Method | Description | Parameters |
| ------------------------ | ------------------ | -------------------- |
| app.updateDeviceInfo() | Update device info | { authKey?, data } |
Usage Examples
Example 1: Get Listings
import TradlySDK from "tradly";
// With auth package (keys auto-injected)
const [error, response] = await TradlySDK.app.getListings({
bodyParam: {
page: 1,
per_page: 20,
type: "listings",
},
});
if (error) {
console.error("Error:", error);
} else {
console.log("Listings:", response.data);
}Example 2: Create Listing
const [error, response] = await TradlySDK.app.postListing({
data: {
title: "My Product",
description: "Product description",
price: 99.99,
// ... other fields
},
});
if (!error) {
console.log("Listing created:", response.data);
}Example 3: Add to Cart
const [error, response] = await TradlySDK.app.addToCart({
data: {
listing_id: 123,
quantity: 2,
// ... other fields
},
});Example 4: Checkout
const [error, response] = await TradlySDK.app.checkout({
data: {
// Checkout data
},
currency: "USD",
});Example 5: Get Orders
const [error, response] = await TradlySDK.app.getOrders({
bodyParam: {
page: 1,
per_page: 10,
status: "pending",
},
});Parameters
Common Parameters
Most methods accept these optional parameters:
authKey- User authentication key (auto-injected if@tradly/authis used)currency- Currency code (e.g., "USD", "EUR")language- Language code (e.g., "en", "fr")bodyParam- Query parameters object (converted to URL query string)
bodyParam Example
const [error, response] = await TradlySDK.app.getListings({
bodyParam: {
page: 1,
per_page: 20,
search: "laptop",
category_id: 5,
},
});
// Converts to: ?page=1&per_page=20&search=laptop&category_id=5Error Handling
All methods return error-first callback pattern:
const [error, response] = await TradlySDK.app.getListings({});
if (error) {
// Handle error
console.error("Error Code:", error.code);
console.error("Error Message:", error.message);
console.error("Full Error:", error);
} else {
// Use response
console.log("Status:", response.status);
console.log("Data:", response.data);
}Integration with @tradly/auth
Automatic Key Injection
When @tradly/auth is installed and initialized:
- PK Key: Automatically injected from auth's cache
- Auth Key: Automatically injected from auth's storage
- Environment: Synced from auth config
- Base URL: Uses auth's baseUrl
Manual Override
You can still manually provide authKey to override auto-injection:
// Manual authKey overrides auto-injected key
const [error, response] = await TradlySDK.app.getListings({
authKey: "custom-key", // Overrides auto-injected
bodyParam: {},
});Environment Variables
Tradly sdk supports these environments:
production- Production API (https://api.tradly.app)development- Development API (https://api.dev.tradly.app)sandbox- Sandbox API (https://api.sandbox.tradly.app)
Best Practices
- Initialize Once: Initialize auth or tradly once at app startup
- Use Auth Package: For automatic key management, use
@tradly/auth - Error Handling: Always check for errors before using response
- TypeScript: Use TypeScript for better type safety
- Async/Await: Use async/await for cleaner code
TypeScript Support
While tradly is written in JavaScript, it works with TypeScript:
import TradlySDK from "tradly";
const [error, response]: [any, any] = await TradlySDK.app.getListings({
bodyParam: {},
});Community Support
For general help using Tradly:
License
ISC
Repository
https://github.com/TRADLY-PLATFORM
Note: This SDK automatically integrates with @tradly/auth when available.
For authentication, we recommend using @tradly/auth package which provides
automatic key management, storage, and better developer experience.
