Skip to main content

News (JavaScript SDK)

  • Last updated
  • View as Markdown

Retrieve news articles for any supported stock symbol.

Making Requests​

Use the news() method on the stocks resource to fetch news.

Output FormatResult PayloadDescription
internal (default)StockNews[] or StockNewsHuman[]Array of decoded news articles.
jsonRaw JSON objectThe compressed, array-keyed response object.
csvBlobCSV payload. Use .save(filename) to write it.

news​

// Positional form
news<P>(
symbol: string,
params?: P,
): MarketDataPromise<StockNews[] | StockNewsHuman[]>

// Object form
news<P>(
params: P & { symbol: string },
): MarketDataPromise<StockNews[] | StockNewsHuman[]>

Fetches news articles for a single symbol.

Parameters​

  • symbol (string)

    The stock symbol to fetch news for.

  • from (string | Date, optional)

    Start of the date range for news articles.

  • to (string | Date, optional)

    End of the date range for news articles.

  • date (string | Date, optional)

    Fetch news for a specific date.

  • countback (number, optional)

    Number of articles to return, counting backwards from to.

  • outputFormat (optional): The format of the returned data. Alias: format.

  • dateFormat (optional): Date format. Alias: dateformat.

  • columns (optional): Columns to include.

  • addHeaders (optional): Whether to include headers in CSV output. Alias: headers.

  • useHumanReadable (optional): Use human-readable field names. Alias: human.

  • mode (optional): The data mode to use.

Returns​

import { MarketDataClient } from "@marketdata/sdk";

const client = new MarketDataClient();

try {
const articles = await client.stocks.news("AAPL");
for (const a of articles) {
console.log(`${a.source}: ${a.headline}`);
}
} catch (error) {
console.error(error);
}

StockNews​

interface StockNews {
s?: string;
symbol: string;
headline: string;
content: string;
source: string;
publicationDate: number;
}

Properties​

  • symbol (string): The stock symbol.
  • headline (string): The news headline.
  • content (string): The article content or summary.
  • source (string): The news source publisher.
  • publicationDate (number): Unix timestamp when the article was published.

StockNewsHuman​

StockNewsHuman is returned when human: true is set. It uses the same field names as StockNews for most columns, but with Symbol capitalized.