woolworths_get_specials
Retrieve current special offers and deals from Woolworths Australia, with optional filtering by product category to find relevant discounts.
Instructions
Get current specials and deals from Woolworths
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Optional category filter (e.g., 'fruit-veg', 'meat-seafood') | |
| pageSize | No | Number of results to return (default: 20) |
Implementation Reference
- src/index.ts:415-441 (handler)The main handler function that implements the logic for woolworths_get_specials tool, fetching specials from Woolworths API using session cookies.
async function handleGetSpecials(args: any): Promise<any> { const category = args.category || ""; const pageSize = args.pageSize ?? 20; let url = `https://www.woolworths.com.au/apis/ui/browse/category`; if (category) { url += `?category=${encodeURIComponent(category)}&filter=Specials&pageSize=${pageSize}`; } else { url += `?category=specials&pageSize=${pageSize}`; } try { const data = await makeWoolworthsRequest(url); return { success: true, category: category || "all", totalResults: data.TotalRecordCount || 0, products: data.Products || data.Bundles || [], }; } catch (error: any) { return { success: false, error: error.message, }; } } - src/index.ts:117-134 (schema)Input schema definition for the woolworths_get_specials tool, including parameters for category and pageSize.
{ name: "woolworths_get_specials", description: "Get current specials and deals from Woolworths", inputSchema: { type: "object", properties: { category: { type: "string", description: "Optional category filter (e.g., 'fruit-veg', 'meat-seafood')", }, pageSize: { type: "number", description: "Number of results to return (default: 20)", default: 20, }, }, }, }, - src/index.ts:647-649 (registration)Registration and dispatch of the woolworths_get_specials handler in the tool call switch statement.
case "woolworths_get_specials": result = await handleGetSpecials(args || {}); break; - src/index.ts:612-613 (registration)Registration of the tool list including woolworths_get_specials schema via the TOOLS array.
tools: TOOLS, })); - src/index.ts:210-248 (helper)Helper function used by the handler to make authenticated requests to Woolworths API with session cookies.
async function makeWoolworthsRequest( url: string, options: any = {} ): Promise<any> { if (sessionCookies.length === 0) { throw new Error( "No session cookies available. Please use woolworths_get_cookies first." ); } const headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", Accept: "*/*", "Accept-Language": "en-US,en;q=0.9", Origin: "https://www.woolworths.com.au", Referer: "https://www.woolworths.com.au/", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", Priority: "u=1, i", Cookie: getCookieHeader(), ...options.headers, }; const response = await fetch(url, { ...options, headers, }); if (!response.ok) { const errorText = await response.text(); throw new Error( `API request failed: ${response.status} ${response.statusText}. ${errorText}` ); } return response.json(); }