Skip to content

Commit 877db17

Browse files
added 8-K Extractor API + 10-Q extraction example
added Executive Compensation Data API
1 parent 78c1b89 commit 877db17

4 files changed

Lines changed: 215 additions & 10 deletions

File tree

README.md

Lines changed: 136 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ It includes:
66
- Query and Full-Text Search API
77
- Real-Time Stream API
88
- XBRL-to-JSON Converter API + Financial Statements
9-
- 10-K/10-Q Section Extraction API
9+
- 10-K/10-Q/8-K Section Extraction API
1010
- Filing Render & Download API
11+
- Executive Compensation Data API
1112

1213

1314
# Data Coverage
@@ -357,11 +358,11 @@ Note: response is shortened.
357358

358359
> See the documentation for more details: https://sec-api.io/docs/xbrl-to-json-converter-api
359360
360-
# 10-K/10-Q Section Extractor API
361+
# 10-K/10-Q/8-K Section Extractor API
361362

362-
The Extractor API returns individual sections from 10-Q and 10-K filings. The extracted section is cleaned and standardized - in raw text or in standardized HTML. You can programmatically extract one or multiple sections from any 10-Q and 10-K filing.
363+
The Extractor API returns individual sections from 10-Q, 10-K and 8-K filings. The extracted section is cleaned and standardized - in raw text or in standardized HTML. You can programmatically extract one or multiple sections from any 10-Q, 10-K and 8-K filing.
363364

364-
All 10-K and 10-Q sections can be extracted:
365+
**All 10-K sections can be extracted:**
365366

366367
- 1 - Business
367368
- 1A - Risk Factors
@@ -383,24 +384,97 @@ All 10-K and 10-Q sections can be extracted:
383384
- 13 - Certain Relationships and Related Transactions, and Director Independence
384385
- 14 - Principal Accountant Fees and Services
385386

387+
**All 10-Q sections can be extracted:**
388+
389+
Part 1:
390+
- 1 - Financial Statements
391+
- 2 - Management’s Discussion and Analysis of Financial Condition and Results of Operations
392+
- 3 - Quantitative and Qualitative Disclosures About Market Risk
393+
- 4 - Controls and Procedures
394+
395+
Part 2:
396+
- 1 - Legal Proceedings
397+
- 1A - Risk Factors
398+
- 2 -Unregistered Sales of Equity Securities and Use of Proceeds
399+
- 3 - Defaults Upon Senior Securities
400+
- 4 - Mine Safety Disclosures
401+
- 5 - Other Information
402+
- 6 - Exhibits
403+
404+
**All 8-K sections can be extracted:**
405+
406+
- 1.01: Entry into a Material Definitive Agreement
407+
- 1.02: Termination of a Material Definitive Agreement
408+
- 1.03: Bankruptcy or Receivership
409+
- 1.04: Mine Safety - Reporting of Shutdowns and Patterns of Violations
410+
- 2.01: Completion of Acquisition or Disposition of Assets
411+
- 2.02: Results of Operations and Financial Condition
412+
- 2.03: Creation of a Direct Financial Obligation or an Obligation under an Off-Balance Sheet Arrangement of a Registrant
413+
- 2.04: Triggering Events That Accelerate or Increase a Direct Financial Obligation or an Obligation under an Off-Balance Sheet Arrangement
414+
- 2.05: Cost Associated with Exit or Disposal Activities
415+
- 2.06: Material Impairments
416+
- 3.01: Notice of Delisting or Failure to Satisfy a Continued Listing Rule or Standard; Transfer of Listing
417+
- 3.02: Unregistered Sales of Equity Securities
418+
- 3.03: Material Modifications to Rights of Security Holders
419+
- 4.01: Changes in Registrant's Certifying Accountant
420+
- 4.02: Non-Reliance on Previously Issued Financial Statements or a Related Audit Report or Completed Interim Review
421+
- 5.01: Changes in Control of Registrant
422+
- 5.02: Departure of Directors or Certain Officers; Election of Directors; Appointment of Certain Officers: Compensatory Arrangements of Certain Officers
423+
- 5.03: Amendments to Articles of Incorporation or Bylaws; Change in Fiscal Year
424+
- 5.04: Temporary Suspension of Trading Under Registrant's Employee Benefit Plans
425+
- 5.05: Amendments to the Registrant's Code of Ethics, or Waiver of a Provision of the Code of Ethics
426+
- 5.06: Change in Shell Company Status
427+
- 5.07: Submission of Matters to a Vote of Security Holders
428+
- 5.08: Shareholder Nominations Pursuant to Exchange Act Rule 14a-11
429+
- 6.01: ABS Informational and Computational Material
430+
- 6.02: Change of Servicer or Trustee
431+
- 6.03: Change in Credit Enhancement or Other External Support
432+
- 6.04: Failure to Make a Required Distribution
433+
- 6.04: Failure to Make a Required Distribution
434+
- 6.04: Failure to Make a Required Distribution
435+
- 6.05: Securities Act Updating Disclosure
436+
- 6.06: Static Pool
437+
- 6.10: Alternative Filings of Asset-Backed Issuers
438+
- 7.01: Regulation FD Disclosure
439+
- 8.01: Other Events
440+
- 9.01: Financial Statements and Exhibits
441+
- Signature
442+
386443
## Usage
387444

388445
```python
389446
from sec_api import ExtractorApi
390447

391448
extractorApi = ExtractorApi("YOUR_API_KEY")
392449

450+
#
451+
# 10-K example
452+
#
393453
# Tesla 10-K filing
394-
filing_url = "https://www.sec.gov/Archives/edgar/data/1318605/000156459021004599/tsla-10k_20201231.htm"
454+
filing_url_10k = "https://www.sec.gov/Archives/edgar/data/1318605/000156459021004599/tsla-10k_20201231.htm"
395455

396456
# get the standardized and cleaned text of section 1A "Risk Factors"
397-
section_text = extractorApi.get_section(filing_url, "1A", "text")
457+
section_text = extractorApi.get_section(filing_url_10k, "1A", "text")
398458

399459
# get the original HTML of section 7 "Management’s Discussion and Analysis of Financial Condition and Results of Operations"
400-
section_html = extractorApi.get_section(filing_url, "7", "html")
460+
section_html = extractorApi.get_section(filing_url_10k, "7", "html")
461+
462+
#
463+
# 10-Q example
464+
#
465+
# Tesla 10-Q filing
466+
filing_url_10q = "https://www.sec.gov/Archives/edgar/data/1318605/000095017022006034/tsla-20220331.htm"
467+
468+
# extract section 1A "Risk Factors" in part 2 as cleaned text
469+
extracted_section_10q = extractorApi.get_section(filing_url_10q, "part2item1a", "text")
470+
471+
#
472+
# 8-K example
473+
#
474+
filing_url_8k = "https://www.sec.gov/Archives/edgar/data/66600/000149315222016468/form8-k.htm"
401475

402-
print(section_text)
403-
print(section_html)
476+
# extract section 1.01 "Entry into Material Definitive Agreement" as cleaned text
477+
extracted_section_8k = extractorApi.get_section(filing_url_8k, "1-1", "text")
404478
```
405479

406480
> See the documentation for more details: https://sec-api.io/docs/sec-filings-item-extraction-api
@@ -500,6 +574,59 @@ result4 = mappingApi.resolve("exchange", "NASDAQ")
500574

501575
> See the documentation for more details: https://sec-api.io/docs/mapping-api
502576
577+
# Executive Compensation Data API
578+
579+
The API provides standardized compensation data of all key executives as reported in SEC filing DEF 14A. The dataset is updated in real-time.
580+
581+
You can search compensation data by 13 parameters, such as company ticker, executive name & position, annual salary, option awards and more.
582+
583+
```python
584+
from sec_api import ExecCompApi
585+
586+
execCompApi = ExecCompApi("YOUR_API_KEY")
587+
588+
# Get data by ticker
589+
result_ticker = execCompApi.get_data("TSLA")
590+
591+
# Get data by CIK
592+
result_cik = execCompApi.get_data("789019")
593+
594+
# List all exec compensations of CIK 70858 for year 2020 and 2019
595+
# Sort result by year first, by name second
596+
query = {
597+
"query": {"query_string": {"query": "cik:70858 AND (year:2020 OR year:2019)"}},
598+
"from": "0",
599+
"size": "200",
600+
"sort": [{"year": {"order": "desc"}}, {"name.keyword": {"order": "asc"}}],
601+
}
602+
result_query = execCompApi.get_data(query)
603+
```
604+
605+
### Response Example
606+
```json
607+
[
608+
{
609+
"id": "8e9177e3bcdb30ada8d092c195bd9d63",
610+
"cik": "1318605",
611+
"ticker": "TSLA",
612+
"name": "Andrew Baglino",
613+
"position": "SVP, Powertrain and Energy Engineering",
614+
"year": 2020,
615+
"salary": 283269,
616+
"bonus": 0,
617+
"stockAwards": 0,
618+
"optionAwards": 46261354,
619+
"nonEquityIncentiveCompensation": 0,
620+
"changeInPensionValueAndDeferredEarnings": 0,
621+
"otherCompensation": 0,
622+
"total": 46544623
623+
}
624+
// and many more
625+
]
626+
```
627+
628+
> See the documentation for more details: https://sec-api.io/docs/executive-compensation-api
629+
503630

504631
# Query API Response Format
505632

examples.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from sec_api.index import RenderApi, XbrlApi, ExtractorApi, MappingApi
1+
from sec_api.index import RenderApi, XbrlApi, ExtractorApi, MappingApi, ExecCompApi
22

33
#
44
# Render API
@@ -66,3 +66,32 @@
6666
6767
print(result)
6868
# """
69+
70+
71+
#
72+
# Executive Compensation Data API Example
73+
#
74+
"""
75+
execCompApi = ExecCompApi("YOUR_API_KEY")
76+
77+
# Get data by ticker
78+
result_ticker = execCompApi.get_data("TSLA")
79+
80+
# Get data by CIK
81+
result_cik = execCompApi.get_data("789019")
82+
83+
# List all exec compensations of CIK 70858 for year 2020 and 2019
84+
# Sort result by year first, by name second
85+
query = {
86+
"query": {"query_string": {"query": "cik:70858 AND (year:2020 OR year:2019)"}},
87+
"from": "0",
88+
"size": "200",
89+
"sort": [{"year": {"order": "desc"}}, {"name.keyword": {"order": "asc"}}],
90+
}
91+
result_query = execCompApi.get_data(query)
92+
93+
94+
print(result_ticker)
95+
print(result_cik)
96+
print(result_query)
97+
# """

sec_api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
from sec_api.index import XbrlApi
66
from sec_api.index import ExtractorApi
77
from sec_api.index import MappingApi
8+
from sec_api.index import ExecCompApi

sec_api/index.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
xbrl_api_endpoint = "https://api.sec-api.io/xbrl-to-json"
1010
extractor_api_endpoint = "https://api.sec-api.io/extractor"
1111
mapping_api_endpoint = "https://api.sec-api.io/mapping"
12+
exec_comp_api_endpoint = "https://api.sec-api.io/compensation"
1213

1314

1415
class QueryApi:
@@ -227,3 +228,50 @@ def resolve(self, parameter="", value=""):
227228
else:
228229
# request failed
229230
raise Exception("API error")
231+
232+
233+
class ExecCompApi:
234+
"""
235+
Base class of Executive Compensation Data API
236+
Documentation: https://sec-api.io/docs/executive-compensation-api
237+
"""
238+
239+
def __init__(self, api_key):
240+
self.api_key = api_key
241+
self.api_endpoint = exec_comp_api_endpoint
242+
243+
def get_data(self, parameter=""):
244+
if isinstance(parameter, str):
245+
http_method = "GET"
246+
elif isinstance(parameter, dict):
247+
http_method = "POST"
248+
else:
249+
raise Exception("Invalid parameter")
250+
251+
# use backoff strategy to handle "too many requests" error.
252+
for x in range(3):
253+
if http_method == "GET":
254+
_url = (
255+
self.api_endpoint
256+
+ "/"
257+
+ parameter.upper()
258+
+ "?token="
259+
+ self.api_key
260+
)
261+
response = requests.get(_url)
262+
else:
263+
_url = self.api_endpoint + "?token=" + self.api_key
264+
response = requests.post(_url, json=parameter)
265+
266+
if response.status_code == 200:
267+
return response.json()
268+
elif response.status_code == 429:
269+
# wait 500 * (x + 1) milliseconds and try again
270+
time.sleep(0.5 * (x + 1))
271+
else:
272+
raise Exception(
273+
"API error: " + str(response.status_code) + " - " + response.text
274+
)
275+
else:
276+
# request failed
277+
raise Exception("API error")

0 commit comments

Comments
 (0)