Skip to main content

Unofficial facade for the sec-api.io, SEC EDGAR 10-Q document downloader

Project description

sec-api-io

GitHub Workflow Status PyPI - Python Version PyPI version Licence

Unofficial wrapper for the sec-api.io API. Built with nbdev.

Install and Setup

Run in terminal:

pip install sec_api_io

How to use

(Optional) Set API key with .env file

It’s highly recommended to set your API key in a .env file to avoid setting it in the code.

  1. Make a copy of the .env.template file in the root directory of the project.
  2. Rename the copied file to .env.
  3. Open the .env file and locate the SECAPIO_API_KEY variable.
  4. Fill in the value for the SECAPIO_API_KEY variable.
    • You can obtain a free key from sec-api.io.
    • Note: The first 100 requests are free.
  5. Save the .env file 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 access sec-api.io API.

Let’s load the API key from .env file into the environment variable SECAPIO_API_KEY

!pip install -q python-dotenv
from dotenv import load_dotenv

load_dotenv() # Load the API key from .env file into the environment variable SECAPIO_API_KEY
import os 
from dotenv import load_dotenv

if 'SECAPIO_API_KEY' not in os.environ:
    assert load_dotenv()

Get latest 10-Q report by ticker

from sec_api_io.secapio_data_retriever import SecapioDataRetriever

retriever = SecapioDataRetriever()
# retriever = SecapioDataRetriever(api_key=...) # If you don't want to use .env file

metadata = retriever.retrieve_report_metadata('10-Q', latest_from_ticker='AAPL')
url = metadata["linkToFilingDetails"]

assert url.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 sections

html = retriever.get_report_html('10-Q', url)
assert html
for line in html.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...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sec-api-io-0.0.14.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

sec_api_io-0.0.14-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file sec-api-io-0.0.14.tar.gz.

File metadata

  • Download URL: sec-api-io-0.0.14.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for sec-api-io-0.0.14.tar.gz
Algorithm Hash digest
SHA256 b80f25e04e53875da9dd25948562c5741fa4558e7e5615f15f4e25d595f7266b
MD5 7330b7a44cbe038b66201a9536c8ddbe
BLAKE2b-256 9172492eae5f8b9443b26bdf55b675ee250cb42afbf30cb469b11ca7189be494

See more details on using hashes here.

File details

Details for the file sec_api_io-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: sec_api_io-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for sec_api_io-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 3b4ccf41e2c7cdbc7a87edd0fd9389e929dbc3c93ec1c802d09dc851142e8a75
MD5 6e42b80191a711bc1b6caac6a22fad13
BLAKE2b-256 9663e229169abcc9ee540952732d8cb364e6a4a6e70dd9f32c00aa585d588487

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page