I am trying to get S-1 balance sheets, income statements, etc. using Python. I've used a lot of packages (sec_api, edgar and others) trying to get the data, but I haven't been able to get it.
Could you provide a package or script how to get S-1 statements?
I am trying this code but it doesn't work for S-1:
import pandas as pd
from sec_api import XbrlApi
API_KEY= *
xbrlApi = XbrlApi(API_KEY)
url_s1_grdn = 'https://www.sec.gov/Archives/edgar/data/1802255/000119312523250013/d492014ds1.htm'
grdn_xbrl_json = xbrlApi.xbrl_to_json(htm_url=url_s1_grdn)
# convert XBRL-JSON of income statement to pandas dataframe
def get_income_statement(xbrl_json):
income_statement_store = {}
# iterate over each US GAAP item in the income statement
for usGaapItem in xbrl_json['StatementsOfIncome']:
values = []
indicies = []
for fact in xbrl_json['StatementsOfIncome'][usGaapItem]:
# only consider items without segment. not required for our analysis.
if 'segment' not in fact:
index = fact['period']['startDate'] + '-' + fact['period']['endDate']
# ensure no index duplicates are created
if index not in indicies:
values.append(fact['value'])
indicies.append(index)
income_statement_store[usGaapItem] = pd.Series(values, index=indicies)
income_statement = pd.DataFrame(income_statement_store)
# switch columns and rows so that US GAAP items are rows and each column header represents a date range
return income_statement.T
income_statement_grdn = get_income_statement(grdn_xbrl_json)
print("Income statement of Guardian Pharmacy Services 2022 S-1 filing as dataframe")
print('---------------------------------------------------------')
income_statement_grdn
The S-1 filing in question doesn't have XBRL data attached which is necessary for a successful conversion and access to its financial statements. Consequently the XBRL-to-JSON Converter API returns an empty response, specifically a 424 error stating "The filer did not attach XBRL data to the filing. A conversion is not possible.". This is because the S-1 filing doesn't include structured XBRL data.
Please note that not all S-1 filings are released with structured XBRL data.
You can always make a manual check if a filing (e.g. S-1) has XBRL data by visiting the filing's details page.
Given your S-1 URL
https://www.sec.gov/Archives/edgar/data/1802255/000119312523250013/d492014ds1.htm
simply replace the last part d492014ds1.htm
with the accession number from the URL 000119312523250013
, add two hyphens -
and -index.html
to get 0001193125-23-250013-index.html
.
The filing's details page URL is:
https://www.sec.gov/Archives/edgar/data/1802255/000119312523250013/0001193125-23-250013-index.html
Now let's look at another S-1 filing that has XBRL data attached to it:
https://www.sec.gov/Archives/edgar/data/1021917/000149315223043907/forms-1.htm
Filing's details page:
https://www.sec.gov/Archives/edgar/data/1021917/000149315223043907/0001493152-23-043907-index.htm