0

Is there a way to automatically download the excel files from the Interactive Data webpage within EDGAR for a list of tickers without having to manually search for each ticker on EDGAR? Or is there a way to get to the XBRL for a range of companies without having to again physically go to each page within EDGAR? I am having trouble with this because I cannot figure out how to generate a unique URL given the last six numbers have to do with the sequence of the filing for that year and account number.

phl194
  • 25
  • 1
  • 7

1 Answers1

0

Edgar does not have an API. I wrote a package that serves as an interface to Edgar that allows searching by tickers. The bit that parses the search results page is below. The whole file is at https://github.com/andrewkittredge/financial_fundamentals/blob/master/financial_fundamentals/edgar.py.

SEARCH_URL = ('http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&'
          'CIK={symbol}&type={filing_type}&dateb=&owner=exclude&count=100')
def _get_document_page_urls(symbol, filing_type):
    '''Get the edgar filing document pages for the CIK.

    '''
    search_url = SEARCH_URL.format(symbol=symbol, filing_type=filing_type)
    search_results_page = get_edgar_soup(url=search_url)
    xbrl_rows = [row for row in 
             search_results_page.findAll('tr') if 
             row.find(text=re.compile('Interactive Data'))]
    for xbrl_row in xbrl_rows:
        documents_page = xbrl_row.find('a', {'id' : 'documentsbutton'})['href']
        documents_url = 'http://sec.gov' + documents_page
        yield documents_url
andrewkittredge
  • 742
  • 5
  • 12