@finlight/n8n-nodes-finlight 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ali
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # @finlight/n8n-nodes-finlight
2
+
3
+ **Official n8n integration for [finlight](https://finlight.me)** — a real-time news and finance API for geopolitics, markets, and macro headlines.
4
+
5
+ This package adds native nodes to [n8n](https://n8n.io) to let you consume and query finlight data inside your automated workflows.
6
+
7
+ ---
8
+
9
+ ## ✨ Features
10
+
11
+ - ✅ `finlight Webhook Trigger` — Listen to live streaming events
12
+ - ✅ `finlight Article Search` — Query articles via REST API with flexible filters
13
+ - 🔐 Supports API Key and Basic Auth
14
+
15
+ ---
16
+
17
+ ## 🚀 Installation
18
+
19
+ If you're using a self-hosted n8n instance:
20
+
21
+ ```bash
22
+ npm install @finlight/n8n-nodes-finlight
23
+ ````
24
+
25
+ Then set the custom extension path in your environment or config:
26
+
27
+ ```env
28
+ N8N_CUSTOM_EXTENSIONS=/path/to/node_modules/@finlight/n8n-nodes-finlight
29
+ ```
30
+
31
+ Restart n8n and you'll see the `finlight` nodes available in the editor.
32
+
33
+ ---
34
+
35
+ ## 🧪 Included Nodes
36
+
37
+ ### 🔔 `finlight Webhook Trigger`
38
+
39
+ Listen to webhook events sent from finlight (e.g. breaking news, alerts, geopolitical headlines).
40
+
41
+ **Manual webhook registration is required.**
42
+
43
+ You can create webhooks in your account at:
44
+ 🔧 [app.finlight.me](https://app.finlight.me)
45
+
46
+ Authentication options:
47
+
48
+ * `x-finlight-key` header
49
+ * Basic Auth
50
+
51
+ ---
52
+
53
+ ### 📡 `finlight Article Search`
54
+
55
+ Fetch news articles from the finlight `/v2/articles` REST API using a flexible set of parameters:
56
+
57
+ * `query`
58
+ * `sources` (array)
59
+ * `excludeSources` (array)
60
+ * `tickers` (array)
61
+ * `from`, `to`, `language`, `order`, `page`, `pageSize`
62
+ * `includeContent`, `includeEntities`, `excludeEmptyContent`
63
+
64
+ See full API reference at:
65
+ 📚 [docs.finlight.me](https://docs.finlight.me)
66
+
67
+ ---
68
+
69
+ ## 📦 Development
70
+
71
+ Clone the repo and build:
72
+
73
+ ```bash
74
+ npm install
75
+ npm run build
76
+ ```
77
+
78
+ To test with your local n8n instance:
79
+
80
+ ```bash
81
+ export N8N_CUSTOM_EXTENSIONS=/absolute/path/to/dist
82
+ n8n start
83
+ ```
84
+
85
+ Or map `dist/` into Docker if using a container setup.
86
+
87
+ ---
88
+
89
+ ## 📘 License
90
+
91
+ [MIT](./LICENSE) – by [finlight](https://finlight.me)
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FinlightArticleSearch = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class FinlightArticleSearch {
6
+ constructor() {
7
+ this.description = {
8
+ displayName: "finlight Article Search",
9
+ name: "finlightArticleSearch",
10
+ group: ["transform"],
11
+ version: 1,
12
+ description: "Search articles using the finlight REST API",
13
+ defaults: {
14
+ name: "finlight Article Search",
15
+ },
16
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
17
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
18
+ icon: "file:../finlight.svg",
19
+ credentials: [
20
+ {
21
+ name: "finlightApi",
22
+ required: true,
23
+ },
24
+ ],
25
+ properties: [
26
+ {
27
+ displayName: "Query",
28
+ name: "query",
29
+ type: "string",
30
+ required: false,
31
+ default: "",
32
+ },
33
+ {
34
+ displayName: "Sources",
35
+ name: "sources",
36
+ type: "fixedCollection",
37
+ placeholder: "Add Source",
38
+ default: {},
39
+ typeOptions: {
40
+ multipleValues: true,
41
+ },
42
+ options: [
43
+ {
44
+ name: "sourceList",
45
+ displayName: "Source List",
46
+ values: [
47
+ {
48
+ displayName: "Source",
49
+ name: "source",
50
+ type: "string",
51
+ default: "",
52
+ },
53
+ ],
54
+ },
55
+ ],
56
+ },
57
+ {
58
+ displayName: "Exclude Sources",
59
+ name: "excludeSources",
60
+ type: "fixedCollection",
61
+ placeholder: "Exclude Source",
62
+ default: {},
63
+ typeOptions: {
64
+ multipleValues: true,
65
+ },
66
+ options: [
67
+ {
68
+ name: "sourceList",
69
+ displayName: "Source List",
70
+ values: [
71
+ {
72
+ displayName: "Source",
73
+ name: "source",
74
+ type: "string",
75
+ default: "",
76
+ },
77
+ ],
78
+ },
79
+ ],
80
+ },
81
+ {
82
+ displayName: "From (ISO date)",
83
+ name: "from",
84
+ type: "string",
85
+ default: "",
86
+ },
87
+ {
88
+ displayName: "To (ISO date)",
89
+ name: "to",
90
+ type: "string",
91
+ default: "",
92
+ },
93
+ {
94
+ displayName: "Language",
95
+ name: "language",
96
+ type: "string",
97
+ default: "en",
98
+ },
99
+ {
100
+ displayName: "Order",
101
+ name: "order",
102
+ type: "options",
103
+ options: [
104
+ { name: "DESC", value: "DESC" },
105
+ { name: "ASC", value: "ASC" },
106
+ ],
107
+ default: "DESC",
108
+ },
109
+ {
110
+ displayName: "Page Size",
111
+ name: "pageSize",
112
+ type: "number",
113
+ default: 20,
114
+ typeOptions: { minValue: 1, maxValue: 100 },
115
+ },
116
+ {
117
+ displayName: "Page",
118
+ name: "page",
119
+ type: "number",
120
+ default: 1,
121
+ typeOptions: { minValue: 1 },
122
+ },
123
+ {
124
+ displayName: "Include Content",
125
+ name: "includeContent",
126
+ type: "boolean",
127
+ default: false,
128
+ },
129
+ {
130
+ displayName: "Include Entities",
131
+ name: "includeEntities",
132
+ type: "boolean",
133
+ default: false,
134
+ },
135
+ {
136
+ displayName: "Exclude Empty Content",
137
+ name: "excludeEmptyContent",
138
+ type: "boolean",
139
+ default: false,
140
+ },
141
+ {
142
+ displayName: "Tickers",
143
+ name: "tickers",
144
+ type: "fixedCollection",
145
+ placeholder: "Add Ticker",
146
+ default: {},
147
+ typeOptions: {
148
+ multipleValues: true,
149
+ },
150
+ options: [
151
+ {
152
+ name: "tickerList",
153
+ displayName: "Ticker List",
154
+ values: [
155
+ {
156
+ displayName: "Ticker",
157
+ name: "ticker",
158
+ type: "string",
159
+ default: "",
160
+ },
161
+ ],
162
+ },
163
+ ],
164
+ },
165
+ ],
166
+ };
167
+ }
168
+ async execute() {
169
+ const items = this.getInputData();
170
+ const returnData = [];
171
+ const apiKey = (await this.getCredentials("finlightApi"));
172
+ for (let i = 0; i < items.length; i++) {
173
+ const body = {};
174
+ const query = this.getNodeParameter("query", i);
175
+ if (query)
176
+ body.query = query;
177
+ const from = this.getNodeParameter("from", i);
178
+ if (from)
179
+ body.from = from;
180
+ const to = this.getNodeParameter("to", i);
181
+ if (to)
182
+ body.to = to;
183
+ const sourcesRaw = this.getNodeParameter("sources.sourceList", i, []);
184
+ if (sourcesRaw.length) {
185
+ body.sources = sourcesRaw.map(s => s.source);
186
+ }
187
+ const excludeSourcesRaw = this.getNodeParameter("excludeSources.sourceList", i, []);
188
+ if (excludeSourcesRaw.length) {
189
+ body.excludeSources = excludeSourcesRaw.map(s => s.source);
190
+ }
191
+ const tickersRaw = this.getNodeParameter("tickers.tickerList", i, []);
192
+ if (tickersRaw.length) {
193
+ body.tickers = tickersRaw.map(t => t.ticker);
194
+ }
195
+ body.language = this.getNodeParameter("language", i);
196
+ body.order = this.getNodeParameter("order", i);
197
+ body.pageSize = this.getNodeParameter("pageSize", i);
198
+ body.page = this.getNodeParameter("page", i);
199
+ body.includeContent = this.getNodeParameter("includeContent", i);
200
+ body.includeEntities = this.getNodeParameter("includeEntities", i);
201
+ body.excludeEmptyContent = this.getNodeParameter("excludeEmptyContent", i);
202
+ const response = await this.helpers.httpRequest({
203
+ method: "POST",
204
+ url: "https://api.finlight.me/v2/articles",
205
+ headers: {
206
+ "Content-Type": "application/json",
207
+ "x-api-key": apiKey.apiKey,
208
+ },
209
+ body,
210
+ json: true,
211
+ });
212
+ returnData.push(...(Array.isArray(response.articles) ? response.articles : [response]));
213
+ }
214
+ return [this.helpers.returnJsonArray(returnData)];
215
+ }
216
+ }
217
+ exports.FinlightArticleSearch = FinlightArticleSearch;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FinlightApi = void 0;
4
+ class FinlightApi {
5
+ constructor() {
6
+ this.name = "finlightApi";
7
+ this.displayName = "finlight API Key";
8
+ this.properties = [
9
+ {
10
+ displayName: "API Key",
11
+ name: "apiKey",
12
+ type: "string",
13
+ default: "",
14
+ },
15
+ ];
16
+ }
17
+ }
18
+ exports.FinlightApi = FinlightApi;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAuthHeaders = getAuthHeaders;
4
+ function getAuthHeaders(params) {
5
+ const headers = {};
6
+ if (params.authentication === "apiKey" && params.apiKey) {
7
+ headers["x-finlight-key"] = params.apiKey;
8
+ }
9
+ if (params.authentication === "basicAuth" && params.credentials) {
10
+ const token = Buffer.from(`${params.credentials.user}:${params.credentials.password}`).toString("base64");
11
+ headers["Authorization"] = `Basic ${token}`;
12
+ }
13
+ return headers;
14
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nodes = void 0;
4
+ const FinlightWebhookTrigger_node_1 = require("./triggers/FinlightWebhookTrigger.node");
5
+ const FinlightArticleSearch_node_1 = require("./actions/FinlightArticleSearch.node");
6
+ exports.nodes = [FinlightWebhookTrigger_node_1.FinlightWebhookTrigger, FinlightArticleSearch_node_1.FinlightArticleSearch];
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FinlightWebhookTrigger = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class FinlightWebhookTrigger {
6
+ constructor() {
7
+ this.description = {
8
+ displayName: "finlight Webhook Trigger",
9
+ name: "finlightWebhookTrigger",
10
+ group: ["trigger"],
11
+ version: 1,
12
+ description: "Triggers on new webhook events from finlight",
13
+ defaults: {
14
+ name: "finlight Webhook Trigger",
15
+ },
16
+ inputs: [],
17
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
18
+ credentials: [
19
+ {
20
+ name: "finlightApi",
21
+ required: true,
22
+ displayOptions: {
23
+ show: {
24
+ authentication: ["apiKey"],
25
+ },
26
+ },
27
+ },
28
+ {
29
+ name: "httpBasicAuth",
30
+ required: true,
31
+ displayOptions: {
32
+ show: {
33
+ authentication: ["basicAuth"],
34
+ },
35
+ },
36
+ },
37
+ ],
38
+ properties: [
39
+ {
40
+ displayName: "Authentication Method",
41
+ name: "authentication",
42
+ type: "options",
43
+ options: [
44
+ { name: "API Key Header (x-finlight-key)", value: "apiKey" },
45
+ { name: "Basic Auth", value: "basicAuth" },
46
+ { name: "None", value: "none" },
47
+ ],
48
+ default: "apiKey",
49
+ },
50
+ ],
51
+ webhooks: [
52
+ {
53
+ name: "default",
54
+ httpMethod: "POST",
55
+ responseMode: "onReceived",
56
+ path: "finlight",
57
+ },
58
+ ],
59
+ documentationUrl: "https://docs.finlight.me",
60
+ icon: "file:../finlight.svg",
61
+ };
62
+ this.webhookMethods = {
63
+ default: {
64
+ async checkExists() {
65
+ return true;
66
+ },
67
+ async create() {
68
+ return true;
69
+ },
70
+ async delete() {
71
+ return true;
72
+ },
73
+ },
74
+ };
75
+ }
76
+ async webhook() {
77
+ const req = this.getRequestObject();
78
+ const headers = req.headers;
79
+ const body = req.body;
80
+ const rawBody = this.getBodyData(); // raw JSON string, not parsed
81
+ const authMethod = this.getNodeParameter("authentication", "");
82
+ // Auth: API Key Header
83
+ if (authMethod === "apiKey") {
84
+ const expectedKey = this.getNodeParameter("apiKey", "");
85
+ const receivedKey = headers["x-finlight-key"];
86
+ if (!receivedKey || receivedKey !== expectedKey) {
87
+ throw new Error("Unauthorized: Invalid API key");
88
+ }
89
+ }
90
+ // Auth: Basic
91
+ if (authMethod === "basicAuth") {
92
+ const credentials = await this.getCredentials("httpBasicAuth");
93
+ const authHeader = headers["authorization"];
94
+ const expected = "Basic " + Buffer.from(`${credentials.user}:${credentials.password}`).toString("base64");
95
+ if (authHeader !== expected) {
96
+ throw new Error("Unauthorized: Invalid Basic Auth");
97
+ }
98
+ }
99
+ // Build clean output with optional fields
100
+ const payload = body;
101
+ const output = {
102
+ link: payload.link,
103
+ source: payload.source,
104
+ title: payload.title,
105
+ publishDate: payload.publishDate,
106
+ language: payload.language,
107
+ };
108
+ if (payload.summary)
109
+ output.summary = payload.summary;
110
+ if (payload.content)
111
+ output.content = payload.content;
112
+ if (payload.sentiment)
113
+ output.sentiment = payload.sentiment;
114
+ if (payload.confidence)
115
+ output.confidence = payload.confidence;
116
+ if (payload.images?.length)
117
+ output.images = payload.images;
118
+ if (payload.companies?.length)
119
+ output.companies = payload.companies;
120
+ return {
121
+ workflowData: [[{ json: output }]],
122
+ };
123
+ }
124
+ }
125
+ exports.FinlightWebhookTrigger = FinlightWebhookTrigger;
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@finlight/n8n-nodes-finlight",
3
+ "version": "0.1.0",
4
+ "description": "Official n8n integration for finlight: real-time finance and news API",
5
+ "author": {
6
+ "name": "Ali Büyükkakac",
7
+ "email": "ali@finlight.me"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/jubeiargh/n8n-nodes-finlight.git"
12
+ },
13
+ "engines": {
14
+ "node": ">=20.15"
15
+ },
16
+ "license": "MIT",
17
+ "main": "index.js",
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "lint": "eslint . --ext .ts",
21
+ "test": "jest"
22
+ },
23
+ "dependencies": {
24
+ "n8n-core": "^1.14.1",
25
+ "n8n-workflow": "*"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^24.1.0",
29
+ "@typescript-eslint/eslint-plugin": "^8.38.0",
30
+ "@typescript-eslint/parser": "^8.38.0",
31
+ "eslint": "^9.32.0",
32
+ "eslint-plugin-n8n-nodes-base": "^1.16.3",
33
+ "jest": "^29.4.0",
34
+ "ts-jest": "^29.4.0",
35
+ "typescript": "^5.8.3"
36
+ },
37
+ "keywords": [
38
+ "finlight",
39
+ "webhook",
40
+ "finance",
41
+ "news",
42
+ "n8n-community-node-package"
43
+ ],
44
+ "files": [
45
+ "dist"
46
+ ],
47
+ "n8n": {
48
+ "n8nNodesApiVersion": 1,
49
+ "credentials": [
50
+ "dist/nodes/finlight/credentials/FinlightApi.credentials.js"
51
+ ],
52
+ "nodes": [
53
+ "dist/nodes/finlight/triggers/FinlightWebhookTrigger.node.js",
54
+ "dist/nodes/finlight/actions/FinlightArticleSearch.node.js"
55
+ ]
56
+ },
57
+ "peerDependencies": {
58
+ "n8n-workflow": "*"
59
+ }
60
+ }