question

mattcirelli95 avatar image
4 Likes"
mattcirelli95 asked ·

Historical news data

Working on a student project, how can I get historical news headlines? I've tried using company_api.get_company_news but can only seem to get daily headlines increasing the page size parameter just increases the daily news headlines. Ideally, I want to get like 5-10 daily company headlines going back as far as possible, is this possible? Thanks!

companiesnews
· 2
10 |600 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

I would love to help! What language are you using?

3 Likes 3 · ·

Thank you, I am working with python!

0 Likes 0 · ·

1 Answer

· Write an Answer
mkelly avatar image
3 Likes"
mkelly answered ·

Just to clarify, you found that the following worked for you:

from __future__ import print_function
import time
import intrinio_sdk
from intrinio_sdk.rest import ApiException
from pprint import pprint

intrinio_sdk.ApiClient().configuration.api_key['api_key'] = 'YOUR_API_KEY'

company_api = intrinio_sdk.CompanyApi()

identifier = 'AAPL' # str | A Company identifier (Ticker, CIK, LEI, Intrinio ID)
page_size = 100 # int | The number of results to return (optional) (default to 100)
next_page = '' # str | Gets the next page of data from a previous API call (optional)
titles = []

while next_page != None:
    try:
        api_response = company_api.get_company_news(identifier, page_size=page_size, next_page=next_page)
        next_page = api_response._next_page
        for news in api_response._news:
            # print(news.title) # uncomment if you want to watch the titles as they are pulled
            titles.append(news.title)
    except ApiException as e:
        print("Exception when calling CompanyApi->get_company_news: %s\r\n" % e)

pprint(titles)


and that https://docs.intrinio.com/documentation/api_v2/paging provided the information you were looking for on paging.

· 1 · Share
10 |600 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Yes I can confirm this solved my issue, thanks!

0 Likes 0 · ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.