Node.js Example
Use the financial-news-api
npm package to search for news articles with Node.js. Start by installing the package.
npm install financial-news-api
Next, replace YOUR_API_KEY
with your API key and run the example below. The example returns the first ten articles mentioning Netflix (ticker: NFLX) filed between 1st February 2020 and 20th May 2020. Increment the from
parameter by 10
to get the next ten articles in the search universe.
const { SearchApi } = require('financial-news-api');
const searchApi = SearchApi('YOUR_API_KEY');
const query = {
queryString: 'symbols:NFLX AND publishedAt:[2020-02-01 TO 2020-05-20]',
from: 0,
size: 10,
};
searchApi.getNews(query).then((articles) => console.log(articles));
Response Example
{
"articles": [
{
"title": "FAANG emerges as the latest group to lead the market, Jim Cramer says",
"description": "\"This market's been going through leadership groups like there's no tomorrow,\" the \"Mad Money\" host said.",
"publishedAt": "2020-05-20T22:32:22+0000",
"sourceUrl": "https://www.cnbc.com/2020/05/20/faang-emerges-as-the-latest-group-to-lead-the-market-jim-cramer-says.html",
"source": {
"name": "CNBC",
"id": "cnbc"
},
"symbols": [
"FB",
"AAPL",
"AMZN",
"NFLX",
"GOOGL",
"TGT",
"WMT",
"HD",
"LOW"
],
"sectors": ["Technology", "Consumer Cyclical", "Consumer Defensive"],
"industries": [
"Internet Content & Information",
"Consumer Electronics",
"Specialty Retail",
"Media - Diversified",
"Discount Stores",
"Home Improvement Stores"
],
"imageUrl": "https://image.cnbcfm.com/api/v1/image/103267851-IMG_0161.jpg?v=1545882603",
"id": "01a030ca440ba8732461703e9a906eb7"
},
{
"title": "S&P 500 Clawing Toward 3,000 Milestone Finds Road Getting Harder",
"description": "A rally this week has pushed the S&P 500 Index to 2,972. The 28-point road to 3,000 could be a slog.",
"publishedAt": "2020-05-20T20:18:32.731Z",
"sourceUrl": "https://www.bloomberg.com/news/articles/2020-05-20/s-p-500-s-next-even-number-milestone-will-be-tough-to-reach",
"source": {
"name": "Bloomberg",
"id": "bloomberg"
},
"symbols": ["FB", "AMZN", "NFLX"],
"sectors": ["Technology", "Consumer Cyclical"],
"industries": [
"Internet Content & Information",
"Specialty Retail",
"Media - Diversified"
],
"imageUrl": "https://assets.bwbx.io/images/users/iqjWHBFdfxIU/iiT4fbpCD7v8/v2/-1x-1.png",
"id": "a63b37b42f4c2a856535a3b7e8bb3190"
}
]
}