Social Listening Report calls GET /twitter for a brand query and GET /web for the corresponding pages. The script pulls the public X posts Desearch returned for the last 7 days and three pages of web results, then writes mentions.csv and report.md with posts by day, top posts by engagement, and top web domains. Authors are shown as Account A, Account B and so on.
The problem
A week of posts and pages about a brand is more than one search box can hold. Latest posts on a busy name can fill a result page in a few hours, and web results mix the brand's own pages with everyone else's.
What the app does
- Reads the brand, the X query, the web query and the page offsets from
config.json. - Pulls Latest and Top public posts on X since 7 days ago.
- Pulls three web result pages and drops duplicate URLs.
- Marks a row on topic when the brand word appears in the post text, or in the page title, snippet or URL.
- Writes a CSV and a Markdown report.
How it works
- Posts.
GET /twittertwice:sort=Latestwith your count, andsort=Topwith count 20. OR terms stay inside parentheses so they group with the date filter. - Pages.
GET /webat eachstartvalue in the config. URLs are deduped across pages. - Label. A row is on topic only when the brand word is in the retrieved text, title, snippet or URL.
- Write the sheet and the report.
API details
Verified against the live OpenAPI specification on 2026-11-25. These are schema fields, not a captured run.
The report keeps its X and web inputs separate. The two X requests send query=cfg["x_query"], start_date=since, and either sort=Latest with count=cfg["x_count"] or sort=Top with count=20. Each web request sends query=cfg["web_query"] and one start offset from cfg["web_starts"].
For the domain table, WebSearchResultsResponse.data contains WebResultItem objects. This trimmed response schema keeps the URL and text fields used to label a page and extract its domain:
A page's snippet can be an empty string. Web pagination uses an offset from 0 to 100 and returns up to 20 results per request, so deduplicating URLs across offsets remains a local report step. The X searches have no pagination; the retrieved posts do not establish a complete week of brand mentions.
API reference: GET /twitter, GET /web. Related walkthrough: Social media monitoring with Desearch.
The code
The key comes from the environment and is not written to the output. The extra calls at the end are stored in the raw file with the rest of the run.
Endpoints
GET /twitterGET /web
Example output
The 2026-10-15 sample returned 70 X posts (50 Latest and 20 Top), 69 unique, of which 68 named the brand in the text. The web calls returned 48 results over 3 pages and 38 unique URLs, and all 38 named the brand. 27 were the brand's own pages or app store listings. 11 were other threads, videos and articles. The 50 Latest posts covered about 2.5 hours, so a busy name needs a more frequent run, or Top, for a week view.
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 on the call log. The sample write-up does not add those headers into a single total. See pricing.
Ideas to extend it
- Run it every morning and keep the CSVs.
- Split the web rows into the brand's own domains and everyone else.
- Add the complaint themes from a separate pass over the same posts.
