The News API lets you pull recent news articles for a given ticker.Our news articles are sourced directly from publishers like The Motley Fool, Investing.com, Reuters, and more.We are actively adding more publishers to our network. If you have a publisher that you would like us to add, please email us at [email protected].To get started, please create an account and grab your API key at financialdatasets.ai.You will use the API key to authenticate your API requests.
import requests# add your API key to the headersheaders = { "X-API-KEY": "your_api_key_here"}# set your query paramsticker = 'AAPL'limit = 5 # optional, max is 10# create the URLurl = ( f'https://api.financialdatasets.ai/news' f'?ticker={ticker}' f'&limit={limit}')# make API requestresponse = requests.get(url, headers=headers)# parse news from the responsenews = response.json().get('news')