Daily API Digest
Module 02 · foundations · beginner
learner.json
In n8n, copy this file and paste it onto the canvas, or use Import from File.
{
"name": "02 - Daily API Digest",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "days",
"triggerAtHour": 8
}
]
}
},
"id": "m02-schedule",
"name": "Every Morning",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
0,
0
]
},
{
"parameters": {
"path": "digest",
"responseMode": "responseNode",
"options": {}
},
"id": "m02-webhook",
"name": "Digest API",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
0,
200
],
"webhookId": "course-02-digest"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "s1",
"name": "min_points",
"value": "={{ Number($json.query?.min_points ?? 100) }}",
"type": "number"
},
{
"id": "s2",
"name": "top_n",
"value": "={{ Number($json.query?.top ?? 5) }}",
"type": "number"
}
]
},
"options": {}
},
"id": "m02-settings",
"name": "Settings",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
220,
100
]
},
{
"parameters": {
"url": "https://hn.algolia.com/api/v1/search",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "tags",
"value": "front_page"
},
{
"name": "hitsPerPage",
"value": "50"
}
]
},
"options": {}
},
"id": "m02-http",
"name": "Fetch Front Page",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
440,
100
]
},
{
"parameters": {
"fieldToSplitOut": "hits",
"options": {}
},
"id": "m02-split",
"name": "Split Stories",
"type": "n8n-nodes-base.splitOut",
"typeVersion": 1,
"position": [
660,
100
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose",
"version": 2
},
"conditions": [
{
"id": "f1",
"leftValue": "={{ $json.points }}",
"rightValue": "={{ $('Settings').first().json.min_points }}",
"operator": {
"type": "number",
"operation": "gte"
}
}
],
"combinator": "and"
},
"looseTypeValidation": true,
"options": {}
},
"id": "m02-filter",
"name": "Popular Only",
"type": "n8n-nodes-base.filter",
"typeVersion": 2.2,
"position": [
1100,
100
]
},
{
"parameters": {
"sortFieldsUi": {
"sortField": [
{
"fieldName": "points",
"order": "descending"
}
]
},
"options": {}
},
"id": "m02-sort",
"name": "Most Points First",
"type": "n8n-nodes-base.sort",
"typeVersion": 1,
"position": [
880,
100
]
},
{
"parameters": {
"maxItems": "={{ $('Settings').first().json.top_n }}"
},
"id": "m02-limit",
"name": "Top N",
"type": "n8n-nodes-base.limit",
"typeVersion": 1,
"position": [
1320,
100
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "a1",
"name": "title",
"value": "={{ $json.title }}",
"type": "string"
},
{
"id": "a2",
"name": "url",
"value": "={{ $json.url || 'https://news.ycombinator.com/item?id=' + $json.objectID }}",
"type": "string"
},
{
"id": "a3",
"name": "points",
"value": "={{ $json.points }}",
"type": "number"
},
{
"id": "a4",
"name": "comments",
"value": "={{ $json.num_comments }}",
"type": "number"
},
{
"id": "a5",
"name": "line",
"value": "=• {{ $json.title }} ({{ $json.points }} pts)",
"type": "string"
}
]
},
"options": {}
},
"id": "m02-format",
"name": "Format Story",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
1540,
100
]
},
{
"parameters": {
"aggregate": "aggregateAllItemData",
"destinationFieldName": "stories",
"options": {}
},
"id": "m02-aggregate",
"name": "Build Digest",
"type": "n8n-nodes-base.aggregate",
"typeVersion": 1,
"position": [
1760,
100
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "d1",
"name": "date",
"value": "={{ $now.toFormat('yyyy-MM-dd') }}",
"type": "string"
},
{
"id": "d2",
"name": "count",
"value": "={{ $json.stories.length }}",
"type": "number"
},
{
"id": "d3",
"name": "text",
"value": "={{ $json.stories.map(s => s.line).join('\\n') }}",
"type": "string"
},
{
"id": "d4",
"name": "stories",
"value": "={{ $json.stories }}",
"type": "array"
}
]
},
"options": {}
},
"id": "m02-summary",
"name": "Add Summary",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
1980,
100
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "c1",
"leftValue": "={{ $('Digest API').isExecuted }}",
"rightValue": "",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "m02-if",
"name": "Called via API?",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
2200,
100
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ $json }}",
"options": {}
},
"id": "m02-respond",
"name": "Respond",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
2420,
0
]
},
{
"parameters": {},
"id": "m02-deliver",
"name": "Deliver (Exercise 3)",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
2420,
200
]
}
],
"connections": {
"Every Morning": {
"main": [
[
{
"node": "Settings",
"type": "main",
"index": 0
}
]
]
},
"Digest API": {
"main": [
[
{
"node": "Settings",
"type": "main",
"index": 0
}
]
]
},
"Settings": {
"main": [
[
{
"node": "Fetch Front Page",
"type": "main",
"index": 0
}
]
]
},
"Fetch Front Page": {
"main": [
[
{
"node": "Split Stories",
"type": "main",
"index": 0
}
]
]
},
"Split Stories": {
"main": [
[
{
"node": "Most Points First",
"type": "main",
"index": 0
}
]
]
},
"Popular Only": {
"main": [
[
{
"node": "Top N",
"type": "main",
"index": 0
}
]
]
},
"Most Points First": {
"main": [
[
{
"node": "Popular Only",
"type": "main",
"index": 0
}
]
]
},
"Top N": {
"main": [
[
{
"node": "Format Story",
"type": "main",
"index": 0
}
]
]
},
"Format Story": {
"main": [
[
{
"node": "Build Digest",
"type": "main",
"index": 0
}
]
]
},
"Build Digest": {
"main": [
[
{
"node": "Add Summary",
"type": "main",
"index": 0
}
]
]
},
"Add Summary": {
"main": [
[
{
"node": "Called via API?",
"type": "main",
"index": 0
}
]
]
},
"Called via API?": {
"main": [
[
{
"node": "Respond",
"type": "main",
"index": 0
}
],
[
{
"node": "Deliver (Exercise 3)",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"settings": {
"executionOrder": "v1"
}
}