-
Notifications
You must be signed in to change notification settings - Fork 24
/
examples.py
380 lines (299 loc) · 7.34 KB
/
examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
from sec_api.index import (
RenderApi,
PdfGeneratorApi,
XbrlApi,
ExtractorApi,
MappingApi,
DirectorsBoardMembersApi,
ExecCompApi,
InsiderTradingApi,
FormNportApi,
FormDApi,
FormAdvApi,
FloatApi,
Form13DGApi,
Form_S1_424B4_Api,
SubsidiaryApi,
AaerApi,
SroFilingsApi,
Item_4_02_Api,
)
#
# Render API
#
"""
renderApi = RenderApi("YOUR_API_KEY")
# 10-K HTM File URL example
filing_data = renderApi.get_filing(
# url="https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926.htm"
url="https://www.sec.gov/ix?doc=/Archives/edgar/data/1320695/000132069520000148/ths12-31x201910krecast.htm"
)
print(filing_data[:300])
# for non-text data, such as a PDF files or an images,
# use get_file() and set `return_binary=True` to get the binary data
pdf_file_url = (
"https://www.sec.gov/Archives/edgar/data/1798925/999999999724004095/filename1.pdf"
)
binary_data = renderApi.get_file(pdf_file_url, return_binary=True)
with open("filename.pdf", "wb") as f:
f.write(binary_data)
# """
#
# PDF Generator API
#
"""
pdfGeneratorApi = PdfGeneratorApi("YOUR_API_KEY")
# Form 8-K exhibit URL
edgar_file_url = "https://www.sec.gov/ix?doc=/Archives/edgar/data/1320695/000132069520000148/ths12-31x201910krecast.htm"
# Form 10-K filing URL
# edgar_file_url = "https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926.htm"
pdf_file = pdfGeneratorApi.get_pdf(edgar_file_url)
with open("filename.pdf", "wb") as f:
f.write(pdf_file)
# """
#
# XBRL-to-JSON API example
#
"""
xbrlApi = XbrlApi("YOUR_API_KEY")
# 10-K HTM File URL example
xbrl_json_1 = xbrlApi.xbrl_to_json(
htm_url="https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926.htm"
)
# print(xbrl_json_1["StatementsOfIncome"])
# print(xbrl_json_1["BalanceSheets"])
# print(xbrl_json_1["StatementsOfCashFlows"])
# 10-K XBRL File URL example
xbrl_json_2 = xbrlApi.xbrl_to_json(
xbrl_url="https://www.sec.gov/Archives/edgar/data/1318605/000156459021004599/tsla-10k_20201231_htm.xml"
)
# 10-K XBRL File URL example
xbrl_json_3 = xbrlApi.xbrl_to_json(accession_no="0001564590-21-004599")
# """
#
# Extractor API Example
#
"""
extractorApi = ExtractorApi("YOUR_API_KEY")
# Tesla 10-K filing
filing_url = "https://www.sec.gov/Archives/edgar/data/1318605/000156459021004599/tsla-10k_20201231.htm"
section_text = extractorApi.get_section(filing_url, "1A", "text")
section_html = extractorApi.get_section(filing_url, "1A", "html")
print(section_text)
print(section_html)
# """
#
# Mapping API Example
#
"""
mappingApi = MappingApi("YOUR_API_KEY")
result = mappingApi.resolve("cik", "927355")
print(result)
# """
#
# Directors & Board Members API Example
#
"""
directorsBoardMembersApi = DirectorsBoardMembersApi("YOUR_API_KEY")
query = {
"query": "ticker:AMZN",
"from": 0,
"size": 50,
"sort": [{"filedAt": {"order": "desc"}}],
}
response = directorsBoardMembersApi.get_data(query)
print(response["data"])
# """
#
# Executive Compensation Data API Example
#
"""
execCompApi = ExecCompApi("YOUR_API_KEY")
# Get data by ticker
result_ticker = execCompApi.get_data("TSLA")
# Get data by CIK
result_cik = execCompApi.get_data("789019")
# List all exec compensations of CIK 70858 for year 2020 and 2019
# Sort result by year first, by name second
query = {
"query": {"query_string": {"query": "cik:70858 AND (year:2020 OR year:2019)"}},
"from": "0",
"size": "200",
"sort": [{"year": {"order": "desc"}}, {"name.keyword": {"order": "asc"}}],
}
result_query = execCompApi.get_data(query)
print(result_ticker)
print(result_cik)
print(result_query)
# """
#
# Insider Trading Data API Example
#
"""
insiderTradingApi = InsiderTradingApi("YOUR_API_KEY")
insider_trades = insiderTradingApi.get_data(
{
"query": "issuer.tradingSymbol:TSLA",
"from": "0",
"size": "50",
"sort": [{"filedAt": {"order": "desc"}}],
}
)
print(insider_trades["transactions"])
# """
#
# Form NPORT API Example
#
"""
nportApi = FormNportApi("YOUR_API_KEY")
response = nportApi.get_data(
{
"query": "fundInfo.totAssets:[100000000 TO *]",
"from": "0",
"size": "2",
"sort": [{"filedAt": {"order": "desc"}}],
}
)
print(response["filings"])
# """
#
# Form D API Example
#
"""
formDApi = FormDApi("YOUR_API_KEY")
response = formDApi.get_data(
{
"query": "offeringData.offeringSalesAmounts.totalOfferingAmount:[1000000 TO *]",
"from": "0",
"size": "10",
"sort": [{"filedAt": {"order": "desc"}}],
}
)
print(response["offerings"])
# """
#
# Form ADV API Example
#
"""
formAdvApi = FormAdvApi("YOUR_API_KEY")
response = formAdvApi.get_firms(
{
"query": "Info.FirmCrdNb:361",
"from": "0",
"size": "10",
"sort": [{"Info.FirmCrdNb": {"order": "desc"}}],
}
)
print(response["filings"])
direct_owners = formAdvApi.get_direct_owners(crd="793")
print(direct_owners)
indirect_owners = formAdvApi.get_indirect_owners(crd="326262")
print(indirect_owners)
private_funds = formAdvApi.get_private_funds(crd="793")
print(private_funds)
response = formAdvApi.get_individuals(
{
"query": "CrntEmps.CrntEmp.orgPK:149777",
"from": "0",
"size": "10",
"sort": [{"id": {"order": "desc"}}],
}
)
print(response["filings"])
response = formAdvApi.get_brochures(149777)
print(response["brochures"])
# """
#
# Float API Example
#
"""
floatApi = FloatApi("YOUR_API_KEY")
response = floatApi.get_float(ticker="TSLA")
print(response["data"])
response = floatApi.get_float(cik="1318605")
print(response["data"])
# """
#
# Form 13D/13G API Example
#
"""
form13DGApi = Form13DGApi("YOUR_API_KEY")
query = {
"query": "accessionNo:*",
"from": "0",
"size": "50",
"sort": [{"filedAt": {"order": "desc"}}],
}
response = form13DGApi.get_data(query)
print(response["filings"])
# """
#
# Form S-1/424B4 API Example
#
"""
form_s1_424B4_api = Form_S1_424B4_Api("YOUR_API_KEY")
query = {
"query": "ticker:V",
"from": "0",
"size": "50",
"sort": [{"filedAt": {"order": "desc"}}],
}
response = form_s1_424B4_api.get_data(query)
print(response["data"])
# """
#
# Subsidiary API Example
#
"""
subsidiaryApi = SubsidiaryApi("YOUR_API_KEY")
query = {
"query": "ticker:TSLA",
"from": "0",
"size": "50",
"sort": [{"filedAt": {"order": "desc"}}],
}
response = subsidiaryApi.get_data(query)
print(response["data"])
# """
#
# AAER API Example
#
"""
aaerApi = AaerApi("YOUR_API_KEY")
query = {
"query": "dateTime:[2012-01-01 TO 2020-12-31]",
"from": "0",
"size": "50",
"sort": [{"dateTime": {"order": "desc"}}],
}
response = aaerApi.get_data(query)
print(response["data"])
# """
#
# SRO Filings API Example
#
"""
sroFilingsApi = SroFilingsApi("YOUR_API_KEY")
query = {
"query": "sro:NASDAQ",
"from": "0",
"size": "10",
"sort": [{"issueDate": {"order": "desc"}}],
}
response = sroFilingsApi.get_data(query)
print(response["data"])
# """
#
# Form 8-K Item 4.02 API Example
#
"""
item_4_02_api = Item_4_02_Api("YOUR_API_KEY")
query = {
"query": "filedAt:[2010-01-01 TO 2019-12-31]",
"from": "0", # increase by 50 to fetch the next 50 results, e.g. 50 (=page 2), 100 (=page 3), 150 (=page 4), ...
"size": "50",
"sort": [{"filedAt": {"order": "desc"}}],
}
response = item_4_02_api.get_data(query)
print(response["data"])
# """