@trustrails/sdk 0.4.8 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,11 +18,10 @@ const trustrails = new TrustRails('your-api-key');
|
|
|
18
18
|
|
|
19
19
|
// Search for products with filters
|
|
20
20
|
const results = await trustrails.search({
|
|
21
|
-
query: 'laptop',
|
|
22
21
|
brand: 'HP',
|
|
22
|
+
category: 'Laptops',
|
|
23
23
|
minPrice: 400,
|
|
24
24
|
maxPrice: 600,
|
|
25
|
-
category: 'Laptops'
|
|
26
25
|
});
|
|
27
26
|
|
|
28
27
|
console.log(`Found ${results.total} products`);
|
|
@@ -62,7 +61,7 @@ new TrustRails({ apiKey: string, baseUrl?: string })
|
|
|
62
61
|
Search for products. Returns summary data (title, price, availability, category). For full technical specs, call `product(id)` with the product ID.
|
|
63
62
|
|
|
64
63
|
**Parameters:**
|
|
65
|
-
- `options.query?: string` -
|
|
64
|
+
- `options.query?: string` - Refinement terms after brand and category are extracted: model lines, series, variants, technology descriptors, or model numbers (e.g. `'neo'`, `'ultra'`, `'oled'`, `'WH-1000XM5'`). Omit entirely if brand + category fully describe what you want. Never put brand names, product family names, or prices here — use filters.
|
|
66
65
|
- `options.brand?: string` - Filter by brand name (e.g., 'Sony', 'HP', 'Anker')
|
|
67
66
|
- `options.category?: string` - Filter by product category (e.g., 'Laptops', 'Headphones')
|
|
68
67
|
- `options.minPrice?: number` - Minimum price filter in GBP
|
|
@@ -73,23 +72,32 @@ Search for products. Returns summary data (title, price, availability, category)
|
|
|
73
72
|
|
|
74
73
|
**Returns:** Promise resolving to `SearchResponse` containing `products` array and `total` count.
|
|
75
74
|
|
|
76
|
-
**Example:**
|
|
75
|
+
**Example — brand + category only (query omitted):**
|
|
77
76
|
```typescript
|
|
78
77
|
const results = await trustrails.search({
|
|
79
|
-
query: 'laptop',
|
|
80
78
|
brand: 'HP',
|
|
79
|
+
category: 'Laptops',
|
|
81
80
|
minPrice: 400,
|
|
82
81
|
maxPrice: 1000,
|
|
83
|
-
category: 'Laptops',
|
|
84
82
|
sort: 'price_asc'
|
|
85
83
|
});
|
|
86
84
|
```
|
|
87
85
|
|
|
86
|
+
**Example — with model line in query:**
|
|
87
|
+
```typescript
|
|
88
|
+
// 'neo', 'ultra', 'oled' etc. go in query — they refine within brand/category
|
|
89
|
+
const results = await trustrails.search({
|
|
90
|
+
brand: 'Samsung',
|
|
91
|
+
category: 'TVs',
|
|
92
|
+
query: 'qled',
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
88
96
|
**Lite mode (faster responses, smaller payloads):**
|
|
89
97
|
```typescript
|
|
90
98
|
const results = await trustrails.search({
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
brand: 'Anker',
|
|
100
|
+
category: 'Cables & Chargers',
|
|
93
101
|
lite: true // Returns only: id, title, brand, price, availability, image_url, purchase_url
|
|
94
102
|
});
|
|
95
103
|
```
|