Search Target by keyword and get JSON with prices, UPC, specifications and sponsored flags. Built on the Scrapier API: one HTTPS request, no headless browser to run, no parser to maintain.
Quickstart · Fields · CLI · FAQ
-
Get an API key from the Scrapier dashboard. No credit card needed to start.
-
Install:
pip install git+https://github.com/get-scrapier/Target-Search-Scraper
-
Run:
from scrapier_target_search_products import TargetSearchProducts
client = TargetSearchProducts(api_key="sk_live_...") # or set SCRAPIER_API_KEY
print(client.total_results("baking sheet"))
for product in client.iter_search_products("baking sheet",
zip_code="10001",
max_items=100):
if product["is_sponsored"] or product["is_marketplace"]:
continue
print(product["current_price"], product["upc"],
product["product_title"][:50])The same code is in examples/quickstart.py.
- Price monitoring
- Catalog matching
- Competitor research
- Product research
Searches Target for a keyword and walks the results with the full product record -- prices and discounts, the UPC and TCIN, the specifications, the dimensions and the return policy.
The richest Target endpoint here. Note that sponsored results are
included by default, unlike scrapier-target-category.
Wraps the target-search-products endpoint, 28 rows a page.
# 1. A list. For scripts and one-liners.
rows = client.search_products(query, max_items=100)
# 2. A generator. Streams, so you can stop early and stop paying.
for row in client.iter_search_products(query):
handle(row)
# 3. A page at a time. You hold the cursor, so you can resume later.
page = client.search_products_page(query)
save(page.items)
while page.has_more:
page = client.search_products_page(cursor=page.next_cursor)
save(page.items)A Page carries the rows plus the envelope:
page.items # the rows
page.next_cursor # opaque string, or None
page.has_more # bool
page.raw_responses # upstream payloads, when raw_data=True
page.data # the whole envelope
len(page) # number of rowsThis endpoint returns more than rows. These read the extra payloads, one request each:
total_results()— How many products Target says match, which is how you size a walk before starting it.
Observed on live responses, not copied from a schema.
| Field | Notes |
|---|---|
tcin, dpci, upc, parent_tcin, url |
identity -- see the quirks |
product_title, description, highlights |
the text |
current_price, regular_price, formatted_price, price_type |
what it costs now and normally |
discount_amount, discount_percent, on_sale |
the offer |
currency |
the unit |
average_rating, review_count, rating_distribution, recommended_percentage |
how it is rated |
brand, sold_by, is_marketplace |
who sells it -- marketplace listings are not Target's own |
is_sponsored |
whether this is an ad -- on by default, so filter it |
available_online, shipping |
whether and how you can get it |
category_id, category_path, item_type |
classification |
specifications, dimensions, package_dimensions, weight |
the physical detail |
country_of_origin, return_policy |
the fine print |
variants, variation_attributes, relationship_type |
the variants |
image_url, images |
the images |
badges |
the badges on the card |
keyword, search_query, source_url, page, position, total_results, next_page, scraped_at |
request metadata |
| Argument | What it does |
|---|---|
sort_by |
How to order the results. One of: relevance, featured, price_low, price_high, newest, bestselling, rating. |
zip_code |
A ZIP code, for local availability and pricing. Defaults to 52404 server-side, so set it if location matters. |
fetch_product_details |
Load each product's own page for the deep fields. Off by default. |
include_sponsored |
Include paid placements. On by default here and off on scrapier-target-category -- see the quirks. |
include_sponsored defaults to ON here and OFF on
scrapier-target-category. The two endpoints disagree, so a keyword
search and a category browse are not comparable out of the box. Filter
on is_sponsored either way.
is_marketplace and sold_by matter for price work. A
marketplace listing is a third party selling through Target, with its
own price and return terms -- averaging it in with Target's own stock
measures two different things.
upc is here and nowhere else in this family. tcin is
Target's own product number, and dpci is its in-store item code.
Both are more reliable join keys than the URL.
Three price fields. current_price is the number to use,
regular_price is the pre-discount figure, and formatted_price is
the display string. on_sale tells you whether the first two should
differ.
Target sits behind PerimeterX and occasionally blocks a request.
Measured live: one category URL came back 500 with Blocked: HTTP 435 and a captcha script, while a different category answered 200
in the same minute. It is bot detection reacting to the moment, not a
broken endpoint, so keep the client's max_retries above zero.
Each page is a billable request, so bound a broad walk:
client.search_products(query, max_items=200) # stop after 200 rows
client.search_products(query, max_pages=5) # stop after 5 requestsmax_items truncates mid-page rather than buying another page to fill a
quota. Checking your balance is free:
print(client.credits())
print(client.account())AsyncTargetSearchProducts exposes every method TargetSearchProducts
does, with identical arguments.
import asyncio
from scrapier_target_search_products import AsyncTargetSearchProducts
async def main():
async with AsyncTargetSearchProducts() as client:
rows = await client.search_products(query)
asyncio.run(main())For hundreds of inputs, submit one background job instead of paging:
job = client.bulk([...], max_items=1000) # up to 10,000 per input
print(job.job_id, job.status)
rows = job.wait(timeout=1800, poll_interval=5)Reattach from another process with client.job(job_id), then read
job.data.
Submits are deduplicated server-side on the request parameters, so an identical submit returns the job the first one created — including when that job failed. Vary a parameter to force a fresh attempt.
Everything derives from ScrapierError, so one except can catch the
lot while you still get to be specific when it matters.
from scrapier_target_search_products import InsufficientCreditsError, RateLimitError, ScrapierError
try:
rows = client.search_products(query)
except InsufficientCreditsError as exc:
print(f"out of credits: {exc.balance} left, {exc.required} needed")
except RateLimitError as exc:
print(f"slow down for {exc.retry_after}s")
except ScrapierError as exc:
print(f"something else: {exc}")| Exception | When |
|---|---|
ConfigurationError |
no API key, or a reserved parameter was passed |
TransportError |
the request never got a response |
BadRequestError |
400 — bad input |
AuthenticationError |
401 — bad or missing key |
InsufficientCreditsError |
402 with a balance — carries .balance and .required |
NotFoundError |
404 |
RateLimitError |
429 — carries .retry_after |
ScrapeTimeoutError |
504 — the scrape itself ran out of time |
ServiceUnavailableError |
503 |
ServerError |
5xx |
JobFailedError |
a bulk job finished in failed — carries .errors |
APIError |
the base for anything with a status code |
429, 503, 5xx and transport failures are retried automatically with
jittered backoff that honours Retry-After. 400, 401, 404 and a 402
about your balance are not — retrying those only wastes time.
export SCRAPIER_API_KEY=sk_live_...
scrapier-target-search-products <query> --max-items 50 --jsonlJSON on stdout and nothing else, so it pipes. Global flags (--api-key,
--base-url, --timeout, --jsonl, --indent) work anywhere on the
line. Exit codes: 0 success, 2 usage or configuration, 3 API
error.
TargetSearchProducts(
api_key=None, # falls back to $SCRAPIER_API_KEY
base_url=None, # falls back to $SCRAPIER_BASE_URL, then the default
timeout=150.0,
max_retries=3, # for 429/503/5xx and transport failures
http_client=None, # bring your own httpx.Client
)The key is sent in the X-API-Key header only — never in a URL or a
request body, so it will not end up in a proxy log.
Every call also accepts method="GET" if you would rather the
parameters went in the query string, use_proxy=True to route the
scrape through Scrapier's proxy pool, and raw_data=True to get the
upstream payloads instead of parsed rows.
Python 3.9+. The only dependency is httpx. Ships py.typed.
The client code is MIT-licensed. It needs a Scrapier API key, and requests are billed in credits; failed requests are not billed. See pricing. You can start without a credit card.
No. The scrape runs on Scrapier's servers and returns JSON.
Use bulk jobs: submit many inputs as one background job, then job.wait().
Yes. See AGENTS.md, or connect the
Scrapier MCP server.
180+ endpoints across 35+ platforms: browse them all.
Open an issue or read the docs.
MIT. See LICENSE.