Given a free-text Target product query, return genuine matching product summaries with title, brand, price, original price, rating, rating count, TCIN, canonical URL, image URL, and optional store-scoped fulfillment signals. The workflow can verify a resolved PDP and configure a caller-supplied ZIP code for local pickup or delivery context. It is read-only with respect to cart and purchase state.
Use Cases
- Search Target for one or more products by description, brand, model, or attributes.
- Return stable TCINs and canonical product URLs.
- Paginate or sort a Target product collection.
- Verify fulfillment, pickup, shipping, delivery, price, returns, or store-specific availability on a PDP.
- Set the Target session's store-location ZIP code when the caller supplies a postal code.
- Use the browser-rendered search page when the search request or its required parameters are unavailable.
Automation Flow
- For each
{query}, openhttps://www.target.com/s?searchTerm={URL-encoded-query}. Wait for the grid. In the loaded page, useperformance.getEntriesByType('resource').map(entry => new URL(entry.name)).find(url => url.origin === 'https://redsky.target.com' && url.pathname.endsWith('/plp_search_v2') && url.searchParams.get('keyword') === query)to identify its search request (queryis the safely encoded JavaScript string for the caller's search term). Readkeyandpricing_store_idfrom that URL'ssearchParams. If either is missing, use step 5. Never hard-code, log, or return the key. - Use the search response from the current browser session, or reuse the observed request there for additional pages. Keep the observed
key,channel,keyword,page,visitor_id, andpricing_store_id.pricing_store_idcontrols localized pricing;store_idscontrols availability. Only scope availability to a specific store when requested, and use a store ID observed in the session. - Parse
data.search.search_response. Require a nonemptyfacet_listbefore treatingdata.search.products[]as genuine results. Reportmetadata.auto_corrected_keywordwhen present. Paginate withoffset=0,24,48,...; do not usepage_number. - Extract products from
data.search.products[], preferably requiring__typename === "ProductSummary". Read the TCIN from the API object or product URL; never infer an opaque ID from a name. - If the search response or required parameters are unavailable, run the browser extractor below on the search page already opened in step 1. Dismiss any Health Data Consent dialog via its visible Continue shopping control, then wait for the grid.
- For PDP verification, navigate directly to
https://www.target.com/-/A-{tcin}or the known canonicalbuy_url. - When a caller supplies
{postal-code}for local fulfillment, use the shortest available PDP flow: clickbutton#zip-code-id-btnwhen present; otherwise click#web-store-id-msg-btn. In the resulting store/location dialog, fillinput#zip-code-city-or-statewith{postal-code}and submit using the dialog's accessible Continue, Apply, Save, or Done control. Wait for the location state to settle. Do not claim that the ZIP was accepted unless the resulting page or dialog exposes the postal code or updated store context. - Run the PDP/store evaluator below after location selection. Never add to cart, navigate to checkout, or submit an order.
Browser search-page extractor
(() => {
const text = e => (e?.innerText || e?.textContent || e?.getAttribute('aria-label') || '').replace(/\s+/g, ' ').trim();
const cards = [...document.querySelectorAll('[data-test="@web/site-top-of-funnel/ProductCardWrapper"], [data-test*="ProductCardWrapper"]')];
const products = cards.map(card => {
const link = card.querySelector('a[href*="/-/A-"], a[href*="/p/"]');
const href = link?.href || '';
const match = href.match(/(?:\/-\/A-|A-)(\d+)/i);
return {
tcin: match?.[1] || null,
title: text(card.querySelector('[data-test="product-title"], [data-test*="product-title"]')) || text(link),
price: text(card.querySelector('[data-test="product-price"], [data-test*="product-price"]')) || null,
rating: text(card.querySelector('[data-test="ratings"], [data-test*="rating"]')) || null,
product_url: href || null,
card_text: text(card).slice(0, 1200)
};
}).filter(p => p.tcin || p.title || p.product_url);
return {url: location.href, products};
})()PDP, ZIP-code, and fulfillment extractor
Run this on the loaded PDP after any ZIP-code interaction has settled:
(() => {
const text = e => (e?.innerText || e?.textContent || e?.getAttribute('aria-label') || '').replace(/\s+/g, ' ').trim();
const tcin = (location.href.match(/(?:\/-\/A-|A-)(\d+)/i) || [])[1] || null;
const dialog = document.querySelector('[role="dialog"]');
const zipInput = document.querySelector('input#zip-code-city-or-state');
const zipValue = zipInput?.value || null;
const body = text(document.body);
const pick = document.querySelector('#PICKUP');
const ship = document.querySelector('#SHIPPING');
const delivery = document.querySelector('#DELIVERY');
const returnsEl = document.querySelector('#ShippingAndReturns-accordion-scroll-id');
const storeButton = document.querySelector('#web-store-id-msg-btn, #zip-code-id-btn');
const prices = []; const seen = new Set();
for (const e of document.querySelectorAll('span, div, p, h2, h3')) {
const t = text(e);
if (t.includes('$') && t.length < 60 && !seen.has(t)) {
seen.add(t); prices.push({text: t, test: e.getAttribute('data-test')});
if (prices.length >= 25) break;
}
}
const postal = body.match(/\b\d{5}(?:-\d{4})?\b/);
const stock = /[0-9]+ in stock|Limited stock|Only [0-9]+ left/i.exec(body);
return {
url: location.href,
tcin,
title: text(document.querySelector('#pdp-product-title-id, [data-test="product-title"], h1')),
store_selector: text(storeButton) || null,
location_dialog_open: !!dialog,
zip_input_present: !!zipInput,
zip_value: zipValue,
visible_postal_code: postal ? postal[0] : null,
pickup: pick ? {text: text(pick), aria: pick.getAttribute('aria-label') || null} : null,
shipping: ship ? text(ship) : null,
delivery: delivery ? text(delivery) : null,
fulfillment: text(document.querySelector('[aria-label="Fulfillment"]')) || null,
prices,
stock_signal: stock ? stock[0] : null,
returns: returnsEl ? text(returnsEl).slice(0, 2000) : null,
store_context: /Pickup at/i.test(body) ? body.match(/.{0,120}Pickup at.{0,500}/i)?.[0] || null : null
};
})()API product mapping
Map .tcin, .item.product_description.title after HTML-entity decoding, .item.primary_brand.name, .price.formatted_current_price, .price.formatted_comparison_price, .ratings_and_reviews.statistics.rating.average, .ratings_and_reviews.statistics.rating.count, .item.enrichment.buy_url, .item.enrichment.image_info.primary_image.url, and .desirability_cues[].display.
Possible Friction Points
- Target product pages use opaque numeric TCINs such as
/-/A-{tcin}. Resolve them from an API object, search-result href, or caller-supplied URL; never guess them. pricing_store_idandstore_idsare independent: the former affects pricing and the latter scopes availability.- The ZIP/store selector has more than one observed entry control.
button#zip-code-id-btncan open the postal-code flow directly;#web-store-id-msg-btnis another PDP store-selector control. - The observed postal-code field is
input#zip-code-city-or-state. Dialog button labels and generated descendants vary, so use accessible names such as Continue, Apply, Save, or Done rather than a generated button selector. - A ZIP-code field being opened is not proof that the location was saved. Confirm the value or resulting store/location context after submission.
- PDP fulfillment sections commonly use
#PICKUP,#SHIPPING, and#DELIVERY; missing sections do not imply availability. - A cold session may show a Health Data Consent dialog; dismiss its accessible Continue shopping control before interacting with the page.
- If Target presents a CAPTCHA or verification challenge, report that the search is blocked rather than retrying the request or bypassing the challenge.
- The redsky API may return recommendation padding when no genuine matches exist; check
facet_list. - Target titles can contain raw HTML entities; decode them before returning results. Preserve null brand, rating, and price fields, including
See price in cart. - Never add to cart, navigate to checkout, submit an order, or claim pickup eligibility without explicit PDP evidence.
Example Result
{
"url": "https://example.com/-/A-123",
"tcin": "123",
"title": "Example Title",
"store_selector": null,
"location_dialog_open": false,
"zip_input_present": false,
"zip_value": null,
"visible_postal_code": null,
"pickup": null,
"shipping": null,
"delivery": null,
"fulfillment": null,
"prices": [
{
"text": "$12",
"test": null
}
],
"stock_signal": null,
"returns": null,
"store_context": null
}