OpenClawSkills
GitHub

HackerNews Digest

Community

Fetch top stories from HackerNews and summarize them.

Installation

Save this file as `hackernews.js` in your `~/.openclaw/skills/` directory.

Source Code

JavaScript
Tutorial.terminal

// hackernews.js
// Description: Fetches the top 5 stories from Hacker News and returns a digest.

module.exports = async function(context) {
    const fetch = context.fetch || require('node-fetch');
    
    try {
        // 1. Get Top Story IDs
        const topStoriesRes = await fetch('https://hacker-news.firebaseio.com/v0/topstories.json');
        const topStoriesIds = await topStoriesRes.json();
        const top5 = topStoriesIds.slice(0, 5);
        
        const results = [];
        
        // 2. Fetch details for each story
        for (const id of top5) {
            const itemRes = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
            const item = await itemRes.json();
            results.push({
                title: item.title,
                url: item.url,
                score: item.score,
                by: item.by
            });
        }
        
        return {
            status: "success",
            data: results,
            message: "Here are the top 5 Hacker News stories."
        };
    } catch (error) {
        return { status: "error", error: error.message };
    }
};

Live Preview

● Live Demo
Agent Session
Starting session...

How to use

  • Ensure you have the necessary dependencies installed (if any).
  • Place the file in your OpenClaw skills folder (e.g., ~/.openclaw/skills/).
  • Restart your agent or reload configuration.
  • Invoke it using the filename (without extension) as the tool name, or through natural language if the description is clear.