Skip to content

Commit 936a3ae

Browse files
Replace axios with zero-dependency HTTP client
- Replace axios with built-in https module (zero dependencies) - Add keep-alive agent (FIFO, 10 max sockets, 15s timeout) - Add gzip/deflate/br decompression and 3xx redirect following - Add 429 retry with backoff, skip retry on free-tier exhaustion - Parse API error responses ({ status, error }) into structured errors - Move config.js to config/index.js, remove unused io/downloadApiV1 - Move example.js to examples/scripts/playground.js, add 8 example scripts - Add invalid API key test, module export tests (43 total) - Update README links to match new repo (sec-api-io/sec-api-node)
1 parent 7505657 commit 936a3ae

18 files changed

Lines changed: 726 additions & 528 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ node_modules
44
deploy.sh
55
.npmrc
66
.claude
7-
tmp
7+
tmp
8+
TODO.md
9+
/scripts/*

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ const firms = await formAdvApi.getFirms({
883883

884884
</details>
885885

886-
[Full example response](https://github.com/janlukasschroeder/sec-api/blob/master/examples/api-responses/form-adv-firms.json)
886+
[Full example response](https://github.com/sec-api-io/sec-api-node/blob/master/examples/api-responses/form-adv-firms.json)
887887

888888
### Search Individual Advisors
889889

@@ -965,7 +965,7 @@ const individuals = await formAdvApi.getIndividuals({
965965

966966
</details>
967967

968-
[Full example response](https://github.com/janlukasschroeder/sec-api/blob/master/examples/api-responses/form-adv-individuals.json)
968+
[Full example response](https://github.com/sec-api-io/sec-api-node/blob/master/examples/api-responses/form-adv-individuals.json)
969969

970970
### Get Direct Owners (Schedule A)
971971

@@ -1005,7 +1005,7 @@ const directOwners = await formAdvApi.getDirectOwners('793');
10051005

10061006
</details>
10071007

1008-
[Full example response](https://github.com/janlukasschroeder/sec-api/blob/master/examples/api-responses/form-adv-direct-owners.json)
1008+
[Full example response](https://github.com/sec-api-io/sec-api-node/blob/master/examples/api-responses/form-adv-direct-owners.json)
10091009

10101010
### Get Indirect Owners (Schedule B)
10111011

@@ -1047,7 +1047,7 @@ const indirectOwners = await formAdvApi.getIndirectOwners('326262');
10471047

10481048
</details>
10491049

1050-
[Full example response](https://github.com/janlukasschroeder/sec-api/blob/master/examples/api-responses/form-adv-indirect-owners.json)
1050+
[Full example response](https://github.com/sec-api-io/sec-api-node/blob/master/examples/api-responses/form-adv-indirect-owners.json)
10511051

10521052
### Get Other Business Names (Schedule D, Section 1.B)
10531053

@@ -1097,7 +1097,7 @@ const otherBusinessNames = await formAdvApi.getOtherBusinessNames('149777');
10971097

10981098
</details>
10991099

1100-
[Full example response](https://github.com/janlukasschroeder/sec-api/blob/master/examples/api-responses/form-adv-other-business-names.json)
1100+
[Full example response](https://github.com/sec-api-io/sec-api-node/blob/master/examples/api-responses/form-adv-other-business-names.json)
11011101

11021102
### Get Separately Managed Accounts (Schedule D, Section 5.K)
11031103

@@ -1154,7 +1154,7 @@ const smaData = await formAdvApi.getSeparatelyManagedAccounts('149777');
11541154

11551155
</details>
11561156

1157-
[Full example response](https://github.com/janlukasschroeder/sec-api/blob/master/examples/api-responses/form-adv-separately-managed-accounts.json)
1157+
[Full example response](https://github.com/sec-api-io/sec-api-node/blob/master/examples/api-responses/form-adv-separately-managed-accounts.json)
11581158

11591159
### Get Financial Industry Affiliations (Schedule D, Section 7.A)
11601160

@@ -1191,7 +1191,7 @@ const affiliations =
11911191

11921192
</details>
11931193

1194-
[Full example response](https://github.com/janlukasschroeder/sec-api/blob/master/examples/api-responses/form-adv-financial-industry-affiliations.json)
1194+
[Full example response](https://github.com/sec-api-io/sec-api-node/blob/master/examples/api-responses/form-adv-financial-industry-affiliations.json)
11951195

11961196
### Get Private Funds (Schedule D, Section 7.B.1)
11971197

@@ -1243,7 +1243,7 @@ const privateFunds = await formAdvApi.getPrivateFunds('793');
12431243

12441244
</details>
12451245

1246-
[Full example response](https://github.com/janlukasschroeder/sec-api/blob/master/examples/api-responses/form-adv-private-funds.json)
1246+
[Full example response](https://github.com/sec-api-io/sec-api-node/blob/master/examples/api-responses/form-adv-private-funds.json)
12471247

12481248
### Get Brochures
12491249

@@ -1283,7 +1283,7 @@ const brochures = await formAdvApi.getBrochures('149777');
12831283

12841284
</details>
12851285

1286-
[Full example response](https://github.com/janlukasschroeder/sec-api/blob/master/examples/api-responses/form-adv-brochures.json)
1286+
[Full example response](https://github.com/sec-api-io/sec-api-node/blob/master/examples/api-responses/form-adv-brochures.json)
12871287

12881288
> See the documentation for more details: https://sec-api.io/docs/investment-adviser-and-adv-api
12891289

config.js renamed to config/index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
module.exports = {
2-
io: {
3-
server: 'https://api.sec-api.io:3334',
4-
// server: 'http://localhost:3333',
5-
namespace: {
6-
allFilings: 'all-filings',
7-
},
8-
},
92
queryApi: {
103
endpoint: 'https://api.sec-api.io',
114
},

example.js

Lines changed: 0 additions & 140 deletions
This file was deleted.

examples/scripts/download-api.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const secApi = require('../../index');
4+
5+
const { log } = console;
6+
7+
// use .env if present, otherwise fall back to inline key
8+
let apiKey = 'YOUR_API_KEY';
9+
const envPath = path.join(__dirname, '..', '..', '.env');
10+
if (fs.existsSync(envPath)) {
11+
const match = fs
12+
.readFileSync(envPath, 'utf-8')
13+
.match(/SEC_API_IO_API_KEY=(.+)/);
14+
if (match) {
15+
apiKey = match[1].trim();
16+
}
17+
}
18+
secApi.setApiKey(apiKey);
19+
20+
const main = async () => {
21+
// download a 10-K filing as text
22+
const content = await secApi.downloadApi.getFile(
23+
'https://www.sec.gov/Archives/edgar/data/1318605/000162828025045968/tsla-20250930.htm',
24+
);
25+
26+
log('Content type: ' + typeof content);
27+
log('Content length: ' + content.length + ' characters');
28+
log('First 200 chars:\n' + content.substring(0, 200));
29+
};
30+
31+
main().catch(log);

examples/scripts/extractor-api.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const secApi = require('../../index');
4+
5+
const { log } = console;
6+
7+
// use .env if present, otherwise fall back to inline key
8+
let apiKey = 'YOUR_API_KEY';
9+
const envPath = path.join(__dirname, '..', '..', '.env');
10+
if (fs.existsSync(envPath)) {
11+
const match = fs
12+
.readFileSync(envPath, 'utf-8')
13+
.match(/SEC_API_IO_API_KEY=(.+)/);
14+
if (match) {
15+
apiKey = match[1].trim();
16+
}
17+
}
18+
secApi.setApiKey(apiKey);
19+
20+
const main = async () => {
21+
// extract "Risk Factors" (section 1A) from a Tesla 10-K
22+
const text = await secApi.extractorApi.getSection(
23+
'https://www.sec.gov/Archives/edgar/data/1318605/000156459021004599/tsla-10k_20201231.htm',
24+
'1A',
25+
'text',
26+
);
27+
28+
log('Section 1A length: ' + text.length + ' characters');
29+
log('First 500 chars:\n' + text.substring(0, 500));
30+
};
31+
32+
main().catch(log);

examples/scripts/form-13f-api.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const secApi = require('../../index');
4+
5+
const { log } = console;
6+
7+
// use .env if present, otherwise fall back to inline key
8+
let apiKey = 'YOUR_API_KEY';
9+
const envPath = path.join(__dirname, '..', '..', '.env');
10+
if (fs.existsSync(envPath)) {
11+
const match = fs
12+
.readFileSync(envPath, 'utf-8')
13+
.match(/SEC_API_IO_API_KEY=(.+)/);
14+
if (match) {
15+
apiKey = match[1].trim();
16+
}
17+
}
18+
secApi.setApiKey(apiKey);
19+
20+
const main = async () => {
21+
// Berkshire Hathaway 13F holdings (CIK: 1067983)
22+
const result = await secApi.form13FHoldingsApi.getData({
23+
query: 'cik:1067983',
24+
from: '0',
25+
size: '5',
26+
sort: [{ filedAt: { order: 'desc' } }],
27+
});
28+
29+
log('Total holdings filings: ' + result.total);
30+
31+
result.data.forEach((holding) => {
32+
log(
33+
holding.filedAt + ' | ' + holding.nameOfIssuer + ' | $' + holding.value,
34+
);
35+
});
36+
};
37+
38+
main().catch(log);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const secApi = require('../../index');
4+
5+
const { log } = console;
6+
7+
// use .env if present, otherwise fall back to inline key
8+
let apiKey = 'YOUR_API_KEY';
9+
const envPath = path.join(__dirname, '..', '..', '.env');
10+
if (fs.existsSync(envPath)) {
11+
const match = fs
12+
.readFileSync(envPath, 'utf-8')
13+
.match(/SEC_API_IO_API_KEY=(.+)/);
14+
if (match) {
15+
apiKey = match[1].trim();
16+
}
17+
}
18+
secApi.setApiKey(apiKey);
19+
20+
const main = async () => {
21+
const result = await secApi.fullTextSearchApi.getFilings({
22+
query: '"artificial intelligence"',
23+
formTypes: ['10-K', '10-Q'],
24+
startDate: '2024-01-01',
25+
endDate: '2024-12-31',
26+
});
27+
28+
log('Total filings found: ' + JSON.stringify(result.total));
29+
30+
result.filings.forEach((filing) => {
31+
log(filing.filedAt + ' | ' + filing.formType + ' | ' + filing.companyName);
32+
});
33+
};
34+
35+
main().catch(log);

0 commit comments

Comments
 (0)