sec-api-io
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.
- 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 the
SECAPIO_API_KEYvariable.- You can obtain a free key from sec-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 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
True
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
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
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...
Contributing
Follow these steps to install the project locally for development:
- 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 environmentsource .venv/bin/activate- Install the project with the commandpip install -e ".[dev]"
Metadata
Release files for sec-api-io 0.0.17
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sec-api-io-0.0.17.tar.gz | 15.1 kB | Without provenance | Details for sec-api-io-0.0.17.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sec_api_io-0.0.17-py3-none-any.whl | Python 3 | none | any | Details for sec_api_io-0.0.17-py3-none-any.whl |
Total release size: 27.8 kB
Release files / sec-api-io-0.0.17.tar.gz
| Download URL | sec-api-io-0.0.17.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41b9a4d500d02924d605c94132b39353e326120b6a1898fbff6173b347a3871f
|
|
BLAKE2b-256 checksum How to use checksums |
eea4d3ce4fdfc4f1ca0dcb9b51e05aa169e614b199a6aef21cc2b2ea1a382a31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / sec_api_io-0.0.17-py3-none-any.whl
| Download URL | sec_api_io-0.0.17-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0aaacae9b8d7f2e862b85b0cbba80118e68215c4607bc3d51a16c98478f29f17
|
|
BLAKE2b-256 checksum How to use checksums |
d705ffd62934c26156dfefc8e188f282042570ffe71a3a6a70293dd487a6cbb5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for sec-api-io 0.0.17
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.