News Aggregation¶
FinanceLib supports fetching financial news from multiple sources.
NewsAPI¶
from financelib import NewsAPIQuery
query = NewsAPIQuery() # Uses NEWS_API_APIKEY from environment
# Search articles
articles = query.search_articles(
"Turkish stocks",
sources_from_ids=["bloomberg", "bbc-news"],
limit=5,
print_results=True,
)
# Get all available source IDs
sources = query.get_all_news_source_ids()
Bloomberg Scraping¶
from financelib import BloombergQuery
query = BloombergQuery()
articles = query.search_articles("BIST rally", limit=5)
for article in articles:
print(f"{article.title} - {article.date}")
News Model¶
from financelib import News
article = News({
"title": "BIST Index Hits Record High",
"content": "The Turkish stock market index reached...",
"date": "2026-03-15",
"author": "John Smith",
"category": "markets",
"source": "Bloomberg",
})
# Convert to dictionary
data = article.to_dict()