Snapshots

Pay for outside data once, cap every source, never hide errors

Waiting on you
  • treg first, Apify only for gaps, and a free fallback wherever one exists.
  • Every paid answer is cached and shared, so the same call is paid once per window.
  • Daily, monthly and per-run caps sit on every source.
  • A failure is never shown as a fact: found, truly none, or could not check.
  • The brew-external-data skill lives outside the repo, so not every session sees it.
40dollar daily treg cap
Your call

Rotate the Apify token pasted in chat on 21 Oct, and put the skill in the repo?

AI and models · 6.6

Outside data rules

DraftLast checked Mon Oct 26Owner Param

Answer

How Brew reads data it does not own, through treg, Apify, the public Meta Ad Library and model web search: treg first, a free fallback wherever one exists, every paid answer cached and shared so it is paid for once, a cap on every source, and a failure never shown as a fact.

Today

The sources

Source Used for Client Key Source
treg.to Listening, SERP, keywords, reviews, AI answers, rival ads, shopping treg.js, shared, one per server TREG_TOKEN, agent key brew-live, team squareup, 20,000 calls a day brew/treg.js:1-5 memory brew-apify-watch
Apify Indian marketplaces, quick commerce, Similarweb, Instagram mentions, YouTube clip downloads, Trustpilot backup apify.js APIFY_TOKEN, Starter plan bought 23 Oct brew/apify.js:1-4 memory brew-apify-watch
Meta Ad Library page Free fallback for every Ad Library call reader/adlib.js, headless Chromium, 2 at once none brew/reader/adlib.js:1-9
Model web search Rivals, company facts, the Claude AI answer ai.js search the model's brew/ai.js:62
Connected accounts GA4, Search Console, Instagram, Google Ads: free connectors the brand's grant memory treg-catalog-for-brew

The rules in code

  1. treg first, Apify only where treg has nothing or is weak memory brew-apify-watch.
  2. Data only through treg; assets never. Images, video and voice run on our own Vertex and OpenAI keys memory treg-usage-rules.
  3. Every call goes through the shared client. Never fetch('https://treg.to/...') directly; every Ad Library call goes through adCall(treg, id, o) brew/reader/adlib.js:76 memory brew-external-data-skill.
  4. Paid once per window. The same endpoint and parameters are paid for once per signal window, by any caller on any instance; identical calls in flight share one answer brew/treg.js:11-15 brew/treg.js:57.
Signal Cache window Source
Company, tech stack, whois 720 hours brew/treg.js:20-27
Reviews, SERP, keywords, trends, AI answers, profiles 168 hours brew/treg.js:20-27
Ad libraries, news, web search, shopping, prices 24 hours brew/treg.js:20-27
Anything else TREG_CACHE_HOURS, 24 brew/treg.js:17
Apify reviews actors, other actors 168 hours, 24 hours brew/apify.js:17
Generation, job polling, downloads, failures never cached brew/treg.js:16
  1. No cache: false for read-only data. A caller that needs fresher data passes maxAgeH instead brew/treg.js:64-65 memory treg-usage-rules.
  2. Re-reads reuse what we have: the read keeps the category and its search terms, and reuses the last rivals, terms and questions brew/reader/stages/answers.js:39-47 memory brew-lean-pipeline.
  3. An error is never an empty result. Three branches every time: found, truly none, could not check and retries memory brew-external-data-skill. Apify rows say a platform could not be read, never "not sold there" brew/shelf.js:5.
  4. A fallback must match the paid source's numbers, not just its shape. The Ad Library fallback reads the page itself for its full count; keyword results once gave Snitch 23 ads instead of 516 memory brew-external-data-skill brew/reader/adlib.js:62-75.
  5. Every live call is measured for source health: ok, empty or error, time and cost; the router sends work to the healthiest source first brew/treg.js:76-79 memory brew-apify-watch.
  6. Saved reads heal on open and on the check page, once a day or hourly while errors remain; a stage that reads differently bumps its version, such as ADS_V memory brew-external-data-skill.
  7. Brand-agnostic. Never hardcode a brand; a bucket patch is a stopgap memory brew-external-data-skill.
  8. No captcha bypass. The Ad Library reader stops when the page asks for a captcha brew/reader/adlib.js:37 brew/reader/adlib.js:54.

Caps

Cap Value Scope Source
TREG_DAY_CAP_USD $40 all brands, every instance, a day brew/deploy.sh:41 brew/tools/prod-env.sh:9 brew/treg.js:82
APIFY_BRAND_MONTH_CAP_USD $10 a brand, a month brew/shelf.js:69 brew/tools/prod-env.sh:9
Apify run $0.25 by default through maxTotalChargeUsd a run brew/apify.js:40
LISTEN_RUN_CAP_USD $0.60 a listening run brew/listen-watch.js:684
PULSE_CAP_USD $3 a market pulse run brew/market-pulse.js:318
Brand Book enrichment $0.50 a brand, weekly memory brew-brand-book

Preferred endpoints

The full map is treg-map.js on main; memory keeps the prices of 14 Oct memory treg-catalog-for-brew.

Signal Use Avoid
TikTok search, comments tikhub.tiktok.search.videos, tikhub.tiktok.video.comments, $0.001 anyapi.tiktok.ad_library_search, 25% success
Instagram reels, comments anyapi.instagram.search.reels, anyapi.instagram.post.comments
Reddit tikhub.x.reddit-app-fetch-dynamic-search, $0.001 Reddit's own .json, 403 to our servers memory brew-community-seat
Facebook comments scrapecreators.x.v1-facebook-post-comments routed treg.facebook.post.comments, 26%
Keyword volume dataforseo.google.keywords.volume, $0.09 per 1,000; free through Google Ads when connected
Trends dataforseo.x.keywords-data-dataforseo-trends-explore-live, $0.0012 serpapi, 12 times dearer
AI answers dataforseo.x.ai-optimization-*, $0.004 crawl4ai.ai-search.chatgpt.scrape, 3%; llm-mentions at $0.10
Google ads adyntel.google.ads.transparency, $0.011
Amazon reviews justoneapi.x.amazon-get-product-top-reviews-v1, country-aware crawl4ai, which always reads amazon.com memory brew-apify-watch
Nykaa, Flipkart, Myntra, Blinkit, Zepto, Instamart Apify actors that passed the 23 Oct probe, each with a backup treg has none, request #1171
Video understanding download through treg or Apify, read on our Vertex

Tomorrow

Item Version Tag
treg first, Apify for gaps, a free fallback for every paid source v1 Stays
The brew-external-data skill moved into brew origin/main, so every session sees it v1 Changes
One monthly outside-data cap per brand across treg and Apify, shown to the team v2 New
Source health shown per brand on the watch page with the last good read v1 Changes
Connected first-party data preferred over paid scraping when both exist v2 Changes
Indian marketplaces through treg once request #1171 lands v2 Changes

How we do it

  1. Load the brew-external-data skill before any change that reads or shows outside data memory brew-external-data-skill.
  2. Check the live balance before saying treg is empty; never trust old logs memory treg-usage-rules:
    treg balance
    
  3. Find stragglers that skip the shared client:
    git -C /Users/param/Documents/ChatGPT/brew grep -n "treg.to/call\|adlibrary" origin/main -- '*.js'
    
    Only treg.js, treg-map.js, adlib.js and guarded local tools should show memory brew-external-data-skill.
  4. Audit every brand, then test with treg forced to fail:
    python3 /Users/param/Documents/ChatGPT/.claude/skills/brew-external-data/audit.py brew-prototype
    node /Users/param/Documents/ChatGPT/.claude/skills/brew-external-data/heal-test.mjs <slug>
    
  5. Probe a new Apify actor on real brands before using it: node tools/probe-sources.mjs memory brew-apify-watch.
  6. Tag every call <what>-<slug>, so spend is booked per brand in spend/<YYYY-MM>.json brew/treg.js:3-5 brew/treg.js:121.

Numbers

Metric Definition Value or status Source
treg per brand Estimated monthly treg spend about $10 a brand a month, estimate of 14 Oct memory treg-tool-catalog
Viral finder treg per brand per weekly run $0.015 to $0.04 memory brew-viral-remakes
AI answers weekly check Claude and treg per run about $0.50 brew/live-watch.js:23
Cache hits meter.hits over calls Live, not reported brew/treg.js:67
Source health ok, empty, error by source and month _brew/ops/sources-YYYY-MM.json, /api/admin/sources memory brew-apify-watch
Full reads, 23 Oct Quotes read per brand Arata 2,888 from 21 sources; Nutrova 1,127; Cozy 797 memory brew-apify-watch

Open

  1. The skill is not in the repo. It lives in the parent folder, not on brew origin/main. Proposal: move it into brew/.claude/skills so every Brew session loads it.
  2. One cap per brand. treg is capped per day for all brands, Apify per brand per month. Proposal: add a per-brand monthly treg cap of $15 beside Apify's $10, both shown on the watch page.
  3. The Apify token was pasted in chat on 21 Oct. Proposal: rotate it memory brew-viral-remakes.
Sources
  • brew origin/main b91e364: treg.js:1-139, apify.js:1-54, reader/adlib.js:1-86, shelf.js:1-8 and 69, listen-watch.js:10 and 684, market-pulse.js:318, live-watch.js:21-24, deploy.sh:38-41, tools/prod-env.sh:9-11
  • skill /Users/param/Documents/ChatGPT/.claude/skills/brew-external-data/SKILL.md, with audit.py and heal-test.mjs; not on brew origin/main
  • memory treg-usage-rules, treg-catalog-for-brew, treg-tool-catalog, brew-external-data-skill, brew-apify-watch, brew-lean-pipeline, brew-viral-remakes, brew-community-seat, no-spend-while-building

Source file content/ai-and-models/outside-data-rules.md · For agents: Markdown · JSON