Skip to content
Daily API Digest

Module 02 · foundations · beginner

Exercises 02 · Daily API Digest

Start from workflow/starter.json (triggers, Settings and HTTP Request only) or from your finished lesson workflow.

Exercise 1: Keyword filter

Task: Add an optional ?q= query parameter. When set, only keep stories whose title contains that word (case-insensitive).

Done when: curl 'http://localhost:5678/webhook/digest?min_points=1&q=ai' only returns titles containing "ai".

Hint

Add q to Settings. In the Filter, add a second condition and handle the "no q" case so it doesn't filter everything out.

Exercise 2: Handle "nothing found"

Task: curl 'http://localhost:5678/webhook/digest?min_points=100000' currently returns an empty 200. Make it return {"count":0,"stories":[],"text":""}.

Done when: the call above returns that JSON.

Hint

When a node outputs zero items, nothing after it runs. Look at the node Settings tab for Always Output Data, then make Add Summary ignore empty stories.

Exercise 3: Deliver the digest

Task: Replace Deliver (Exercise 3) with a real delivery: Gmail, Slack, Telegram or Discord (pick one you have).

Done when: running the workflow from the Schedule Trigger (click Execute step on it) delivers text to you.

Hint

Use {{ $json.text }} as the message body and HN Digest {{ $json.date }} as the subject/title.

Stretch: A second source

Add a second HTTP Request (e.g. https://www.reddit.com/r/programming/top.json?t=day) and merge both lists before sorting.