모든 소스
Finnhub Market News
금융 v1.0.0Financial news aggregated from major sources like Yahoo, Reuters, and CNBC via Finnhub
@codytseng #finance #news #market #stocks
설정
| 이름 | 키 | 유형 | 필수 | 기본값 | 설명 |
|---|---|---|---|---|---|
| API Token | FINNHUB_TOKEN | secret | 예 | — | Free API key from finnhub.io |
| News Category | CATEGORY | select | 아니오 | general | Category of financial news generalforexcryptomerger |
소스 코드
version: 1.0.0
name: Finnhub Market News
description: Financial news aggregated from major sources like Yahoo, Reuters, and CNBC via Finnhub
author: codytseng
author_url: https://github.com/codytseng
category: Finance
tags:
- finance
- news
- market
- stocks
config:
- key: FINNHUB_TOKEN
name: API Token
type: secret
required: true
description: Free API key from finnhub.io
- key: CATEGORY
name: News Category
type: select
required: false
default: general
description: Category of financial news
options:
- general
- forex
- crypto
- merger version: 1.0.0
name: Finnhub Market News
description: Financial news aggregated from major sources like Yahoo, Reuters, and CNBC via Finnhub
author: codytseng
author_url: https://github.com/codytseng
category: Finance
tags:
- finance
- news
- market
- stocks
config:
- key: FINNHUB_TOKEN
name: API Token
type: secret
required: true
description: Free API key from finnhub.io
- key: CATEGORY
name: News Category
type: select
required: false
default: general
description: Category of financial news
options:
- general
- forex
- crypto
- merger module.exports = async (api) => {
const token = api.config.get("FINNHUB_TOKEN");
const category = api.config.get("CATEGORY") || "general";
async function fetchData() {
const res = await api.fetch(
`https://finnhub.io/api/v1/news?category=${category}&token=${token}`,
);
if (!res.ok || !res.json) {
throw new Error(`Failed to fetch Finnhub news (HTTP ${res.status})`);
}
const items = res.json.map((article) => ({
id: String(article.id),
title: article.headline,
subtitle: article.summary,
url: article.url,
timestamp: article.datetime,
}));
api.emit(items);
}
await fetchData();
return {
refresh: fetchData,
};
}; module.exports = async (api) => {
const token = api.config.get("FINNHUB_TOKEN");
const category = api.config.get("CATEGORY") || "general";
async function fetchData() {
const res = await api.fetch(
`https://finnhub.io/api/v1/news?category=${category}&token=${token}`,
);
if (!res.ok || !res.json) {
throw new Error(`Failed to fetch Finnhub news (HTTP ${res.status})`);
}
const items = res.json.map((article) => ({
id: String(article.id),
title: article.headline,
subtitle: article.summary,
url: article.url,
timestamp: article.datetime,
}));
api.emit(items);
}
await fetchData();
return {
refresh: fetchData,
};
};