Metadata-Version: 2.1
Name: sec-api-io
Version: 0.0.3
Summary: Unofficial facade for the sec-api.io, SEC EDGAR 10-Q document downloader
Home-page: https://github.com/Elijas/sec-api-io
Author: Elijas
Author-email: 4084885+Elijas@users.noreply.github.com
License: Apache Software License 2.0
Keywords: nbdev jupyter notebook python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: dev
License-File: LICENSE

# sec-api-io

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Install and Setup

Run in terminal:

``` sh
pip install sec_api_io
```

## How to use

### Set API key

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](https://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](https://sec-api.io/) API.

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

``` python
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

``` python
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

``` python
html = retriever.get_report_html('10-Q', url)
assert html
```

``` python
for line in html.splitlines():
    print(line[:50] + '...')
```

    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
    <document-root-section comment="This tag was added...
    <span style="color:#000000;font-family:'Helvetica'...
