Market Research Brief picks one market and builds its brief from three Desearch routes: GET /web for results, GET /web/extract for page text and GET /twitter for recent posts. The script pulls several pages of web results, removes repeated URLs, sets aside store and manufacturer pages, reads the text of the top third-party pages, adds a small sample of recent X posts, and writes brief.md: brands named most often, recurring buyer concerns, price mentions, and the sources it read.
The problem
A market brief starts as a pile of roundup articles, store pages and recent posts. Store pages crowd out reviews. Copying prices and brand names by hand loses the URL they came from.
What the app does
- Reads the market, the web query, page offsets, brand names, store domains, concern terms and an extract limit from
config.json. - Dedupes web results across pages.
- Sets aside URLs on the store and brand domains you listed.
- Reads up to 12 remaining pages with Extract, as text, with JavaScript off.
- Skips pages with under 200 characters of text.
- Adds one Latest X search and writes the brief plus CSV files.
How it works
- Search.
GET /webat eachstartvalue. Pages overlap, so URLs are deduped. - Filter. Store and brand domains from the config are set aside.
- Read.
GET /web/extractwithformat=textandjs=falsefor the first pages that remain. - Posts.
GET /twitterwith your X query,sort=Latestand your count. - Count brand names and concern terms per page, and collect dollar amounts from the page text.
The code
The key comes from the environment and is not written to the output. Pages that return no text are skipped.
Endpoints
GET /webGET /web/extractGET /twitter
API details
| Route | Parameters in this script |
|---|---|
GET /web | query from config, start at each web_starts value |
GET /web/extract | url, format=text, js=false |
GET /twitter | query from config, sort=Latest, count from config |
Trimmed responses, with the field types from openapi.json:
The first is GET /web, the second GET /twitter. GET /web/extract with format=text returns plain text, which is where the brand counts and dollar amounts come from.
Edge cases from the API reference: an empty or whitespace-only query on GET /web returns 422 and is not charged. The code sends one such probe, empty_query in the config. By default format=text returns the main content of a page and can leave out tables and sidebars; full_page=true returns all visible text instead.
Background reading: Search then read: web search API and extract for AI agents.
Example output
The 2026-10-15 sample returned 79 web results and 44 unique URLs. It requested 12 pages and kept 8 with usable text. The brief lists the brands named on the most pages, the concern terms, the dollar amounts it found, and the URLs it read. Full text is in sample-output.md.
Run it yourself
The public examples folder linked above includes the script and a README. Install its requirements, set DESEARCH_API_KEY from console.desearch.ai, and use the run command in that README.
What it costs
Each response records X-Desearch-Cost-Usd. The sample write-up does not add those headers into a single total. A run is several web calls, up to 12 extract calls, and one X call, plus the two check calls stored in the raw file. See pricing.
Ideas to extend it
- Save each brief with the date and diff brand counts week to week.
- Raise the extract limit when the first 12 pages are thin.
- Add Reddit threads for the same buyer concerns with GET /web and site:reddit.com in the query.
