-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathexample.js
More file actions
140 lines (106 loc) · 2.88 KB
/
example.js
File metadata and controls
140 lines (106 loc) · 2.88 KB
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
const secApi = require('./index');
/**
* Set your API key
*/
const yourApiKey = 'YOUR_API_KEY';
secApi.setApiKey(yourApiKey);
/**
* Query API
*/
const { queryApi } = secApi;
const queryExample = async () => {
const query = {
query: { query_string: { query: 'formType:"10-Q"' } },
from: '0',
size: '10',
sort: [{ filedAt: { order: 'desc' } }],
};
const data = await queryApi.getFilings(query);
console.log(data);
};
// uncomment
// queryExample();
/**
* Full-text search API
*/
const { fullTextSearchApi } = secApi;
const fullTextSearchExample = async () => {
const query = {
query: '"LPCN 1154"', // drug
// formTypes: ['8-K', '10-Q'],
startDate: '2021-01-01',
endDate: '2021-06-14',
};
const data = await fullTextSearchApi.getFilings(query);
console.log(data);
};
// uncomment
// fullTextSearchExample();
/**
* Download API
*/
const { downloadApi } = secApi;
const downloadApiExample = async () => {
const filingUrl =
'https://www.sec.gov/Archives/edgar/data/1318605/000162828025045968/tsla-20250930.htm';
const data = await downloadApi.getFile(filingUrl);
console.log(data.slice(0, 1000));
};
// downloadApiExample();
/**
* Render API
*/
const { renderApi } = secApi;
const renderApiExample = async () => {
const filingUrl =
'https://www.sec.gov/Archives/edgar/data/1841925/000121390021032758/ea142795-8k_indiesemic.htm';
const data = await renderApi.getFilingContent(filingUrl);
console.log(data);
};
// uncomment
// renderApiExample();
/**
* Stream API
*/
// const { streamApi } = secApi;
// uncomment
// streamApi.connect(yourApiKey);
// streamApi.on('filing', (filing) => console.log(filing));
// streamApi.on('filings', (filings) => console.log(filings));
/**
* 10-K/10-Q Section Extraction API
*/
const { extractorApi } = secApi;
const extractorApiExample = async () => {
const filingUrl =
'https://www.sec.gov/Archives/edgar/data/1318605/000156459021004599/tsla-10k_20201231.htm';
const sectionText = await extractorApi.getSection(filingUrl, '1A', 'text');
const sectionHtml = await extractorApi.getSection(filingUrl, '1A', 'html');
console.log(sectionText);
console.log(sectionHtml);
};
// uncomment
// extractorApiExample();
/**
* XBRL-to-JSON API
*/
const { xbrlApi } = secApi;
// xbrlApi.setApiKey('YOUR_API_KEY');
// 10-K HTM File URL example
// const xbrlJson = xbrlApi
// .xbrlToJson({
// htmUrl:
// 'https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926.htm',
// })
// .then(console.log);
// 10-K XBRL File URL Example
// const xbrlJson = xbrlApi
// .xbrlToJson({
// xbrlUrl:
// 'https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926_htm.xml',
// })
// .then(console.log);
// 10-K Accession Number Example
// const xbrlJson = xbrlApi
// .xbrlToJson({ accessionNo: '0000320193-20-000096' })
// .then(console.log);