Skip to content

Instantly share code, notes, and snippets.

@janlukasschroeder
Created September 18, 2021 14:36
Show Gist options
  • Save janlukasschroeder/a2c057d2068e5cb57d3c7e37921c6d4c to your computer and use it in GitHub Desktop.
Save janlukasschroeder/a2c057d2068e5cb57d3c7e37921c6d4c to your computer and use it in GitHub Desktop.
from sec_api import XbrlApi
xbrlApi = XbrlApi("YOUR_API_KEY")
# 10-K HTM File URL example
xbrl_json = xbrlApi.xbrl_to_json(
htm_url="https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926.htm"
)
# access income statement, balance sheet and cash flow statement
print(xbrl_json["StatementsOfIncome"])
print(xbrl_json["BalanceSheets"])
print(xbrl_json["StatementsOfCashFlows"])
# 10-K XBRL File URL example
xbrl_json = xbrlApi.xbrl_to_json(
xbrl_url="https://www.sec.gov/Archives/edgar/data/1318605/000156459021004599/tsla-10k_20201231_htm.xml"
)
# 10-K accession number example
xbrl_json = xbrlApi.xbrl_to_json(accession_no="0001564590-21-004599")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment