Package: sec-api-io
sec-api-ioUnofficial wrapper for thesec-api.io API. Built
withnbdev.Install and SetupRun in terminal:pipinstallsec_api_ioHow to use(Optional) Set API key with.envfileIt’s highly recommended to set your API key in a.envfile to avoid
setting it in the code.Make a copy of the.env.templatefile in the root directory of the
project.Rename the copied file to.env.Open the.envfile and locate theSECAPIO_API_KEYvariable.Fill in the value for theSECAPIO_API_KEYvariable.You can obtain a free key fromsec-api.io.Note: The first 100 requests are free.Save the.envfile next to your notebook or script.Important Note:Depending on your geographical location, you might
need to use a VPN set to a United States location to accesssec-api.ioAPI.Let’s load the API key from .env file into the environment variable
SECAPIO_API_KEY!pipinstall-qpython-dotenvfromdotenvimportload_dotenvload_dotenv()# Load the API key from .env file into the environment variable SECAPIO_API_KEYTrueimportosfromdotenvimportload_dotenvif'SECAPIO_API_KEY'notinos.environ:assertload_dotenv()assert'SECAPIO_API_KEY'inos.environimportosfromdotenvimportload_dotenvif'SECAPIO_API_KEY'notinos.environ:assertload_dotenv()assert'SECAPIO_API_KEY'inos.environassertos.environ['SECAPIO_API_KEY'].strip()Get latest 10-Q report by tickerfromsec_api_io.secapio_data_retrieverimportSecapioDataRetrieverretriever=SecapioDataRetriever()# retriever = SecapioDataRetriever(api_key=...) # If you don't want to use .env filemetadata=retriever.retrieve_report_metadata('10-Q',latest_from_ticker='AAPL')url=metadata["linkToFilingDetails"]asserturl.startswith('https://www.sec.gov/Archives/edgar/data/')url'https://www.sec.gov/Archives/edgar/data/320193/000032019323000077/aapl-20230701.htm'Download 10-Q HTML split into sectionshtml=retriever.get_report_html('10-Q',url)asserthtmlforlineinhtml.splitlines():print(line[:65]+'...')<top-level-section-separator id="part1item1" title="Financial Statemen...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...
<top-level-section-separator id="part1item2" title="Management's Discu...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...
<top-level-section-separator id="part1item3" title="Quantitative and Q...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...
<top-level-section-separator id="part1item4" title="Controls and Proce...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...
<top-level-section-separator id="part2item1" title="Legal Proceedings"...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...
<top-level-section-separator id="part2item1a" title="Risk Factors" com...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...
<top-level-section-separator id="part2item2" title="Unregistered Sales...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...
<top-level-section-separator id="part2item3" title="Defaults Upon Seni...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...
<top-level-section-separator id="part2item4" title="Mine Safety Disclo...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...
<top-level-section-separator id="part2item5" title="Other Information"...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...
<top-level-section-separator id="part2item6" title="Exhibits" comment=...
<span style="color:#000000;font-family:'Helvetica',sans-serif;fon...ContributingFollow these steps to install the project locally for development:Install the project with the commandpip install -e ".[dev]".NoteWe highly recommend using virtual environments for Python
development. If you’d like to use virtual environments, follow these
steps instead: - Create a virtual environmentpython3 -m venv .venv- Activate the virtual environmentsource .venv/bin/activate- Install the project with the commandpip install -e ".[dev]"