# sec-api-io
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
<a href="https://github.com/elijas/sec-api-io/actions/workflows/test.yaml"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/elijas/sec-api-io/test.yaml?label=build"></a>
<a href="https://pypi.org/project/sec-api-io/"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/sec-api-io"></a>
<a href="https://badge.fury.io/py/sec-api-io"><img src="https://badge.fury.io/py/sec-api-io.svg" alt="PyPI version" /></a>
<a href="LICENSE"><img src="https://img.shields.io/github/license/elijas/sec-api-io.svg" alt="Licence"></a>
Unofficial wrapper for the [sec-api.io API](https://sec-api.io). Built
with [nbdev](https://nbdev.fast.ai/).
## Install and Setup
Run in terminal:
``` sh
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](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
!pip install -q python-dotenv
```
``` python
from dotenv import load_dotenv
load_dotenv() # Load the API key from .env file into the environment variable SECAPIO_API_KEY
```
True
``` python
import os
from dotenv import load_dotenv
if 'SECAPIO_API_KEY' not in os.environ:
assert load_dotenv()
assert 'SECAPIO_API_KEY' in os.environ
```
``` python
import os
from dotenv import load_dotenv
if 'SECAPIO_API_KEY' not in os.environ:
assert load_dotenv()
assert 'SECAPIO_API_KEY' in os.environ
assert os.environ['SECAPIO_API_KEY'].strip()
```
### 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[: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...
## Contributing
Follow these steps to install the project locally for development:
1. Install the project with the command `pip install -e ".[dev]"`.
> **Note** We highly recommend using virtual environments for Python
> development. If you’d like to use virtual environments, follow these
> steps instead: - Create a virtual environment
> `python3 -m venv .venv` - Activate the virtual environment
> `source .venv/bin/activate` - Install the project with the command
> `pip install -e ".[dev]"`
Raw data
{
"_id": null,
"home_page": "https://github.com/Elijas/sec-api-io",
"name": "sec-api-io",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "nbdev jupyter notebook python",
"author": "Elijas",
"author_email": "4084885+Elijas@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/ee/a4/d3ce4fdfc4f1ca0dcb9b51e05aa169e614b199a6aef21cc2b2ea1a382a31/sec-api-io-0.0.17.tar.gz",
"platform": null,
"description": "# sec-api-io\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n<a href=\"https://github.com/elijas/sec-api-io/actions/workflows/test.yaml\"><img alt=\"GitHub Workflow Status\" src=\"https://img.shields.io/github/actions/workflow/status/elijas/sec-api-io/test.yaml?label=build\"></a>\n<a href=\"https://pypi.org/project/sec-api-io/\"><img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/sec-api-io\"></a>\n<a href=\"https://badge.fury.io/py/sec-api-io\"><img src=\"https://badge.fury.io/py/sec-api-io.svg\" alt=\"PyPI version\" /></a>\n<a href=\"LICENSE\"><img src=\"https://img.shields.io/github/license/elijas/sec-api-io.svg\" alt=\"Licence\"></a>\n\nUnofficial wrapper for the [sec-api.io API](https://sec-api.io). Built\nwith [nbdev](https://nbdev.fast.ai/).\n\n## Install and Setup\n\nRun in terminal:\n\n``` sh\npip install sec_api_io\n```\n\n## How to use\n\n### (Optional) Set API key with `.env` file\n\nIt\u2019s highly recommended to set your API key in a `.env` file to avoid\nsetting it in the code.\n\n1. Make a copy of the `.env.template` file in the root directory of the\n project.\n2. Rename the copied file to `.env`.\n3. Open the `.env` file and locate the `SECAPIO_API_KEY` variable.\n4. Fill in the value for the `SECAPIO_API_KEY` variable.\n - You can obtain a free key from [sec-api.io](https://sec-api.io/).\n - Note: The first 100 requests are free.\n5. Save the `.env` file next to your notebook or script.\n\n> **Important Note:** Depending on your geographical location, you might\n> need to use a VPN set to a United States location to access\n> [sec-api.io](https://sec-api.io/) API.\n\nLet\u2019s load the API key from .env file into the environment variable\nSECAPIO_API_KEY\n\n``` python\n!pip install -q python-dotenv\n```\n\n``` python\nfrom dotenv import load_dotenv\n\nload_dotenv() # Load the API key from .env file into the environment variable SECAPIO_API_KEY\n```\n\n True\n\n``` python\nimport os \nfrom dotenv import load_dotenv\n\nif 'SECAPIO_API_KEY' not in os.environ:\n assert load_dotenv()\n \nassert 'SECAPIO_API_KEY' in os.environ\n```\n\n``` python\nimport os \nfrom dotenv import load_dotenv\n\nif 'SECAPIO_API_KEY' not in os.environ:\n assert load_dotenv()\n \nassert 'SECAPIO_API_KEY' in os.environ\nassert os.environ['SECAPIO_API_KEY'].strip()\n```\n\n### Get latest 10-Q report by ticker\n\n``` python\nfrom sec_api_io.secapio_data_retriever import SecapioDataRetriever\n\nretriever = SecapioDataRetriever()\n# retriever = SecapioDataRetriever(api_key=...) # If you don't want to use .env file\n\nmetadata = retriever.retrieve_report_metadata('10-Q', latest_from_ticker='AAPL')\nurl = metadata[\"linkToFilingDetails\"]\n\nassert url.startswith('https://www.sec.gov/Archives/edgar/data/')\nurl\n```\n\n 'https://www.sec.gov/Archives/edgar/data/320193/000032019323000077/aapl-20230701.htm'\n\n### Download 10-Q HTML split into sections\n\n``` python\nhtml = retriever.get_report_html('10-Q', url)\nassert html\n```\n\n``` python\nfor line in html.splitlines():\n print(line[:65] + '...')\n```\n\n <top-level-section-separator id=\"part1item1\" title=\"Financial Statemen...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n <top-level-section-separator id=\"part1item2\" title=\"Management's Discu...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n <top-level-section-separator id=\"part1item3\" title=\"Quantitative and Q...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n <top-level-section-separator id=\"part1item4\" title=\"Controls and Proce...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n <top-level-section-separator id=\"part2item1\" title=\"Legal Proceedings\"...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n <top-level-section-separator id=\"part2item1a\" title=\"Risk Factors\" com...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n <top-level-section-separator id=\"part2item2\" title=\"Unregistered Sales...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n <top-level-section-separator id=\"part2item3\" title=\"Defaults Upon Seni...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n <top-level-section-separator id=\"part2item4\" title=\"Mine Safety Disclo...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n <top-level-section-separator id=\"part2item5\" title=\"Other Information\"...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n <top-level-section-separator id=\"part2item6\" title=\"Exhibits\" comment=...\n <span style=\"color:#000000;font-family:'Helvetica',sans-serif;fon...\n\n## Contributing\n\nFollow these steps to install the project locally for development:\n\n1. Install the project with the command `pip install -e \".[dev]\"`.\n\n> **Note** We highly recommend using virtual environments for Python\n> development. If you\u2019d like to use virtual environments, follow these\n> steps instead: - Create a virtual environment\n> `python3 -m venv .venv` - Activate the virtual environment\n> `source .venv/bin/activate` - Install the project with the command\n> `pip install -e \".[dev]\"`\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Unofficial facade for the sec-api.io, SEC EDGAR 10-Q document downloader",
"version": "0.0.17",
"project_urls": {
"Homepage": "https://github.com/Elijas/sec-api-io"
},
"split_keywords": [
"nbdev",
"jupyter",
"notebook",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d705ffd62934c26156dfefc8e188f282042570ffe71a3a6a70293dd487a6cbb5",
"md5": "c42567edb9cf76574a2b8f41b0a5af97",
"sha256": "0aaacae9b8d7f2e862b85b0cbba80118e68215c4607bc3d51a16c98478f29f17"
},
"downloads": -1,
"filename": "sec_api_io-0.0.17-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c42567edb9cf76574a2b8f41b0a5af97",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 12705,
"upload_time": "2023-11-22T08:23:52",
"upload_time_iso_8601": "2023-11-22T08:23:52.643992Z",
"url": "https://files.pythonhosted.org/packages/d7/05/ffd62934c26156dfefc8e188f282042570ffe71a3a6a70293dd487a6cbb5/sec_api_io-0.0.17-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "eea4d3ce4fdfc4f1ca0dcb9b51e05aa169e614b199a6aef21cc2b2ea1a382a31",
"md5": "89935d7d34259e6b0589262502d5ce00",
"sha256": "41b9a4d500d02924d605c94132b39353e326120b6a1898fbff6173b347a3871f"
},
"downloads": -1,
"filename": "sec-api-io-0.0.17.tar.gz",
"has_sig": false,
"md5_digest": "89935d7d34259e6b0589262502d5ce00",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 15072,
"upload_time": "2023-11-22T08:23:54",
"upload_time_iso_8601": "2023-11-22T08:23:54.316789Z",
"url": "https://files.pythonhosted.org/packages/ee/a4/d3ce4fdfc4f1ca0dcb9b51e05aa169e614b199a6aef21cc2b2ea1a382a31/sec-api-io-0.0.17.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-22 08:23:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Elijas",
"github_project": "sec-api-io",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "sec-api-io"
}