Back to use cases

    Use case / Developers / Python 3 / Published

    Build a Daily News Digest with Cited Links in Python

    Card for Build a Daily News Digest with Cited Links in Python

    Morning Topic Brief is a small Python script that builds a daily news digest. Every morning it runs one search per topic over the last 24 hours across the web, X, Reddit and Hacker News, and turns the answers into one Markdown digest with cited links. It can also send the digest to a Telegram chat.

    The problem

    Following a few topics means checking news sites, X, Reddit and Hacker News every morning. Feeds are noisy and summaries without sources are hard to trust. A short digest with a link behind every line saves that time.

    What the app does

    • Reads your topics from topics.yaml.
    • Runs one AI Search per topic over the last 24 hours.
    • Turns numbered citations into real links and removes duplicates.
    • Checks each result's own date and tags older or undated sources.
    • Writes the digest to a file, prints it and can post it to Telegram.

    How it works

    1. Search. POST /desearch/ai/search with tools: ["web", "twitter", "reddit", "hackernews"] and a short system message for a cited bullet digest.
    2. Link citations to the result lists.
    3. Check dates on each result.
    4. Write and send the digest, with the total cost from the response headers.

    The code

    def call_http(payload: dict, api_key: str, timeout: int) -> dict:
        """Plain HTTP call. Returns status, headers, body, latency."""
        t0 = time.perf_counter()
        r = requests.post(API_URL, json=payload, timeout=timeout,
                          headers={"Authorization": api_key, "Content-Type": "application/json"})
        latency = time.perf_counter() - t0
        try:
            body = r.json()
        except ValueError:
            body = r.text
        return {"status": r.status_code, "headers": dict(r.headers), "body": body, "latency_s": round(latency, 2)}
    

    The folder has one script, brief.py, an example topics.yaml and a sample digest in sample-output.md.

    Endpoints

    • POST /desearch/ai/search

    Example output

    A 3-topic brief made 3 calls. Each call returned 10 billed units and cost $0.004, so the digest cost $0.012. Each topic gets a few bullets, each bullet with its source links, and older or undated sources are tagged.

    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.

    Optional: set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID to post the digest to a chat. Edit topics.yaml to change topics.

    What it costs

    Every call returned X-Desearch-Cost-Usd: 0.004, so a 3-topic brief cost $0.012 per run. See pricing.

    Ideas to extend it

    • Run it with cron every morning.
    • Send it to Slack or email instead of Telegram.
    • Add a weekly roll-up of the daily digests.

    Use with AI agents

    Point an MCP client at the hosted Desearch server. Replace the placeholder with a key from the console. Do not commit the key.

    {
      "mcpServers": {
        "desearch": {
          "url": "https://mcp.desearch.ai/mcp",
          "headers": {
            "Authorization": "Bearer <DESEARCH_API_KEY>"
          }
        }
      }
    }

    Prompt you can paste for this example:

    Use Desearch to build a morning digest for the topics I name, covering the last 24 hours on the web, X, Reddit, and Hacker News. Cite the links you retrieve. Do not add stories you did not find.

    Build your own example.

    Give your agents access to web and social search. Get an API key to start building, or talk to us about your integration.

    Read docs