Back to use cases

    Use case / AI SEARCH / Python 3 / Published

    Build a Daily News Digest with Cited Links in Python

    Get a morning digest on your topics from the last 24 hours of X, with cited links. Reddit threads use GET /web with site:reddit.com in the query.

    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 on the web and X, and turns the answers into one Markdown digest with cited links. Reddit threads are a separate GET /web query with site:reddit.com in the query. It can also send the digest to a Telegram chat.

    The problem

    Following a few topics means checking the web, X, and Reddit 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"] and a short system message for a cited bullet digest. Supported tools: web, twitter. Other values are unsupported and may be rejected (for example, youtube returns 422). Reddit threads use GET /web with site:reddit.com in query only.
    2. Link citations to the result lists.
    3. Check dates on each result.
    4. Write and send the digest.

    The code

    PYTHON
    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 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

    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.

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

    Prompt you can paste for this example:

    Use Desearch to build a morning digest for the topics I name. Cover the last 24 hours on the web and X. For Reddit threads, call GET /web with site:reddit.com in the query. 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