Stock News
Use TIGER_API::NewsClient to get stock news and market highlights. Follow this SDK's quickstart to configure the client. News queries use the main gateway and do not take over real-time quote device access.
get_stock_news
NewsPage get_stock_news(const utility::string_t &symbol, const utility::string_t &lang = U(""), int page_count = 0, int page_size = 0)
Description
Gets news for one stock using news_stock_list. Only one symbol is supported. Paginate using the page number and page size; the first page starts with the latest articles.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | utility::string_t | Yes | One stock symbol, such as U("AAPL") |
lang | utility::string_t or Language | No | An empty string is omitted by default; a nonempty config.lang takes precedence |
page_count | int | No | 0 is omitted; the server defaults to 1. Explicit values must be at least 1 |
page_size | int | No | 0 is omitted; the server defaults to 20. Explicit values must be 1–50 |
Returns
TIGER_API::NewsPage; throws an exception on failure.
| Field | Type | Description |
|---|---|---|
items | std::vector<NewsItem> | Articles on the current page |
page_count | int | Current page number; always 1 for market highlights |
page_size | int | Page size |
total_page | int | Total page count |
total_size | int | Total item count |
Each news item has the following fields:
| Field | Type | Description |
|---|---|---|
id | utility::string_t | Article ID; can be used as the cursor for the next market-highlights page |
title | utility::string_t | Title |
summary | utility::string_t | Summary |
pub_timestamp | long long | Publication time, as a Unix timestamp in seconds |
url | utility::string_t | Article URL |
Example
#include <iostream>
#include "tigerapi/client_config.h"
#include "tigerapi/news_client.h"
int main() {
using namespace TIGER_API;
ClientConfig config(false, U("your_config_directory_path"));
config.lang = U("en_US");
NewsClient news_client(config);
const auto page = news_client.get_stock_news(U("AAPL"), U("en_US"), 1, 20);
for (const auto &item : page.items)
std::cout << item.pub_timestamp << " " << utility::conversions::to_utf8string(item.title) << std::endl;
}Response example
This JSON example is based on fixed SDK test fixtures and illustrates the response data structure. Actual calls return the SDK objects listed above.
{
"items": [
{
"id": "123456",
"title": "Apple Q2",
"summary": "Earnings beat",
"pubTimestamp": 1729413600,
"url": "https://example.com/news/123456"
}
],
"pageCount": 1,
"pageSize": 20,
"totalPage": 1,
"totalSize": 1
}Request rate
Base limit: 60 requests/minute.
Updated 1 day ago
