@apiverve/earnings 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +217 -0
- package/index.d.ts +47 -0
- package/index.js +215 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 APIVerve, and EvlarSoft LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Earnings Report API
|
|
2
|
+
|
|
3
|
+
Earnings Report is a tool for retrieving company financial data including income statement, balance sheet, and cash flow data from SEC filings. It supports lookup by ticker or CIK with optional year and quarter filters.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
[](https://www.npmjs.com/package/@apiverve/earnings)
|
|
9
|
+
|
|
10
|
+
This is a Javascript Wrapper for the [Earnings Report API](https://apiverve.com/marketplace/earnings?utm_source=npm&utm_medium=readme)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Using npm:
|
|
17
|
+
```shell
|
|
18
|
+
npm install @apiverve/earnings
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Using yarn:
|
|
22
|
+
```shell
|
|
23
|
+
yarn add @apiverve/earnings
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Configuration
|
|
29
|
+
|
|
30
|
+
Before using the Earnings Report API client, you have to setup your account and obtain your API Key.
|
|
31
|
+
You can get it by signing up at [https://apiverve.com](https://apiverve.com?utm_source=npm&utm_medium=readme)
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
[Get started with the Quick Start Guide](https://docs.apiverve.com/quickstart?utm_source=npm&utm_medium=readme)
|
|
38
|
+
|
|
39
|
+
The Earnings Report API documentation is found here: [https://docs.apiverve.com/ref/earnings](https://docs.apiverve.com/ref/earnings?utm_source=npm&utm_medium=readme).
|
|
40
|
+
You can find parameters, example responses, and status codes documented here.
|
|
41
|
+
|
|
42
|
+
### Setup
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
const earningsAPI = require('@apiverve/earnings');
|
|
46
|
+
const api = new earningsAPI({
|
|
47
|
+
api_key: '[YOUR_API_KEY]'
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### Perform Request
|
|
58
|
+
|
|
59
|
+
Using the API is simple. All you have to do is make a request. The API will return a response with the data you requested.
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
var query = {
|
|
63
|
+
ticker: "ADBE",
|
|
64
|
+
year: 2025,
|
|
65
|
+
quarter: 2
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
api.execute(query, function (error, data) {
|
|
69
|
+
if (error) {
|
|
70
|
+
return console.error(error);
|
|
71
|
+
} else {
|
|
72
|
+
console.log(data);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### Using Promises
|
|
80
|
+
|
|
81
|
+
You can also use promises to make requests. The API returns a promise that you can use to handle the response.
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
var query = {
|
|
85
|
+
ticker: "ADBE",
|
|
86
|
+
year: 2025,
|
|
87
|
+
quarter: 2
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
api.execute(query)
|
|
91
|
+
.then(data => {
|
|
92
|
+
console.log(data);
|
|
93
|
+
})
|
|
94
|
+
.catch(error => {
|
|
95
|
+
console.error(error);
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### Using Async/Await
|
|
102
|
+
|
|
103
|
+
You can also use async/await to make requests. The API returns a promise that you can use to handle the response.
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
async function makeRequest() {
|
|
107
|
+
var query = {
|
|
108
|
+
ticker: "ADBE",
|
|
109
|
+
year: 2025,
|
|
110
|
+
quarter: 2
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
const data = await api.execute(query);
|
|
115
|
+
console.log(data);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error(error);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Example Response
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"status": "ok",
|
|
129
|
+
"error": null,
|
|
130
|
+
"data": {
|
|
131
|
+
"ticker": "ADBE",
|
|
132
|
+
"company": "ADOBE INC.",
|
|
133
|
+
"cik": "0000796343",
|
|
134
|
+
"fiscalYear": 2025,
|
|
135
|
+
"fiscalQuarter": 2,
|
|
136
|
+
"filingType": "10-Q",
|
|
137
|
+
"filingDate": "2025-06-25",
|
|
138
|
+
"periodEnd": "2025-05-30",
|
|
139
|
+
"income": {
|
|
140
|
+
"revenue": 11587000000,
|
|
141
|
+
"costOfRevenue": 1260000000,
|
|
142
|
+
"grossProfit": 10327000000,
|
|
143
|
+
"operatingIncome": 4272000000,
|
|
144
|
+
"netIncome": 3502000000,
|
|
145
|
+
"eps": 8.08,
|
|
146
|
+
"epsBasic": 8.1,
|
|
147
|
+
"sharesOutstanding": 433000000,
|
|
148
|
+
"sharesOutstandingBasic": 432000000,
|
|
149
|
+
"researchAndDevelopment": 2108000000,
|
|
150
|
+
"sellingAndMarketing": 3121000000,
|
|
151
|
+
"sellingGeneralAndAdmin": null,
|
|
152
|
+
"generalAndAdmin": 744000000,
|
|
153
|
+
"interestExpense": 68000000,
|
|
154
|
+
"incomeTax": 781000000,
|
|
155
|
+
"depreciation": 82000000,
|
|
156
|
+
"stockBasedCompensation": null
|
|
157
|
+
},
|
|
158
|
+
"balance": {
|
|
159
|
+
"totalAssets": 28107000000,
|
|
160
|
+
"currentAssets": 8978000000,
|
|
161
|
+
"cash": 4931000000,
|
|
162
|
+
"receivables": 1735000000,
|
|
163
|
+
"inventory": null,
|
|
164
|
+
"propertyAndEquipment": 1890000000,
|
|
165
|
+
"goodwill": 12830000000,
|
|
166
|
+
"intangibles": 631000000,
|
|
167
|
+
"totalLiabilities": 16659000000,
|
|
168
|
+
"currentLiabilities": 9039000000,
|
|
169
|
+
"accountsPayable": 360000000,
|
|
170
|
+
"longTermDebt": 6166000000,
|
|
171
|
+
"equity": 11448000000,
|
|
172
|
+
"retainedEarnings": 41744000000
|
|
173
|
+
},
|
|
174
|
+
"cashFlow": {
|
|
175
|
+
"operatingCashFlow": 4673000000,
|
|
176
|
+
"capitalExpenditures": 73000000,
|
|
177
|
+
"freeCashFlow": 4600000000,
|
|
178
|
+
"investingCashFlow": -762000000,
|
|
179
|
+
"financingCashFlow": -6629000000,
|
|
180
|
+
"dividendsPaid": null,
|
|
181
|
+
"shareRepurchases": 6750000000
|
|
182
|
+
},
|
|
183
|
+
"lastUpdated": "2026-02-05T08:00:00.000Z"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Customer Support
|
|
191
|
+
|
|
192
|
+
Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=npm&utm_medium=readme).
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Updates
|
|
197
|
+
|
|
198
|
+
Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Legal
|
|
203
|
+
|
|
204
|
+
All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms?utm_source=npm&utm_medium=readme), [Privacy Policy](https://apiverve.com/privacy?utm_source=npm&utm_medium=readme), and [Refund Policy](https://apiverve.com/refund?utm_source=npm&utm_medium=readme).
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
Licensed under the The MIT License (MIT)
|
|
210
|
+
|
|
211
|
+
Copyright (©) 2026 APIVerve, and EvlarSoft LLC
|
|
212
|
+
|
|
213
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
214
|
+
|
|
215
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
216
|
+
|
|
217
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
declare module '@apiverve/earnings' {
|
|
2
|
+
export interface earningsOptions {
|
|
3
|
+
api_key: string;
|
|
4
|
+
secure?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface earningsResponse {
|
|
8
|
+
status: string;
|
|
9
|
+
error: string | null;
|
|
10
|
+
data: EarningsReportData;
|
|
11
|
+
code?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
interface EarningsReportData {
|
|
16
|
+
ticker: string;
|
|
17
|
+
company: string;
|
|
18
|
+
cik: string;
|
|
19
|
+
fiscalYear: number;
|
|
20
|
+
fiscalQuarter: number;
|
|
21
|
+
filingType: string;
|
|
22
|
+
filingDate: Date;
|
|
23
|
+
periodEnd: Date;
|
|
24
|
+
income: { [key: string]: number | null };
|
|
25
|
+
balance: { [key: string]: number | null };
|
|
26
|
+
cashFlow: CashFlow;
|
|
27
|
+
lastUpdated: Date;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface CashFlow {
|
|
31
|
+
operatingCashFlow: number;
|
|
32
|
+
capitalExpenditures: number;
|
|
33
|
+
freeCashFlow: number;
|
|
34
|
+
investingCashFlow: number;
|
|
35
|
+
financingCashFlow: number;
|
|
36
|
+
dividendsPaid: null;
|
|
37
|
+
shareRepurchases: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default class earningsWrapper {
|
|
41
|
+
constructor(options: earningsOptions);
|
|
42
|
+
|
|
43
|
+
execute(callback: (error: any, data: earningsResponse | null) => void): Promise<earningsResponse>;
|
|
44
|
+
execute(query: Record<string, any>, callback: (error: any, data: earningsResponse | null) => void): Promise<earningsResponse>;
|
|
45
|
+
execute(query?: Record<string, any>): Promise<earningsResponse>;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
class earningsWrapper {
|
|
4
|
+
|
|
5
|
+
constructor(options) {
|
|
6
|
+
if (!options || typeof options !== 'object') {
|
|
7
|
+
throw new Error('Options object must be provided. See documentation: https://docs.apiverve.com/ref/earnings');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { api_key, secure = true } = options;
|
|
11
|
+
|
|
12
|
+
if (!api_key || typeof api_key !== 'string') {
|
|
13
|
+
throw new Error('API key must be provided as a non-empty string. Get your API key at: https://apiverve.com');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Validate API key format (GUID or alphanumeric with hyphens)
|
|
17
|
+
const apiKeyPattern = /^[a-zA-Z0-9-]+$/;
|
|
18
|
+
if (!apiKeyPattern.test(api_key)) {
|
|
19
|
+
throw new Error('Invalid API key format. API key must be alphanumeric and may contain hyphens. Get your API key at: https://apiverve.com');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Check minimum length (GUIDs are typically 36 chars with hyphens, or 32 without)
|
|
23
|
+
const trimmedKey = api_key.replace(/-/g, '');
|
|
24
|
+
if (trimmedKey.length < 32) {
|
|
25
|
+
throw new Error('Invalid API key. API key appears to be too short. Get your API key at: https://apiverve.com');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof secure !== 'boolean') {
|
|
29
|
+
throw new Error('Secure parameter must be a boolean value.');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.APIKey = api_key;
|
|
33
|
+
this.IsSecure = secure;
|
|
34
|
+
|
|
35
|
+
// secure is deprecated, all requests must be made over HTTPS
|
|
36
|
+
this.baseURL = 'https://api.apiverve.com/v1/earnings';
|
|
37
|
+
|
|
38
|
+
// Validation rules for parameters (generated from schema)
|
|
39
|
+
this.validationRules = {"ticker":{"type":"string","required":true,"minLength":1,"maxLength":5},"year":{"type":"integer","required":false,"min":2000,"max":2030},"quarter":{"type":"integer","required":false,"min":1,"max":4}};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Validate query parameters against schema rules
|
|
44
|
+
* @param {Object} query - The query parameters to validate
|
|
45
|
+
* @throws {Error} - If validation fails
|
|
46
|
+
*/
|
|
47
|
+
validateParams(query) {
|
|
48
|
+
const errors = [];
|
|
49
|
+
|
|
50
|
+
for (const [paramName, rules] of Object.entries(this.validationRules)) {
|
|
51
|
+
const value = query[paramName];
|
|
52
|
+
|
|
53
|
+
// Check required
|
|
54
|
+
if (rules.required && (value === undefined || value === null || value === '')) {
|
|
55
|
+
errors.push(`Required parameter [${paramName}] is missing.`);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Skip validation if value is not provided and not required
|
|
60
|
+
if (value === undefined || value === null) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Type validation
|
|
65
|
+
if (rules.type === 'integer' || rules.type === 'number') {
|
|
66
|
+
const numValue = Number(value);
|
|
67
|
+
if (isNaN(numValue)) {
|
|
68
|
+
errors.push(`Parameter [${paramName}] must be a valid ${rules.type}.`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (rules.type === 'integer' && !Number.isInteger(numValue)) {
|
|
73
|
+
errors.push(`Parameter [${paramName}] must be an integer.`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Min/max validation for numbers
|
|
78
|
+
if (rules.min !== undefined && numValue < rules.min) {
|
|
79
|
+
errors.push(`Parameter [${paramName}] must be at least ${rules.min}.`);
|
|
80
|
+
}
|
|
81
|
+
if (rules.max !== undefined && numValue > rules.max) {
|
|
82
|
+
errors.push(`Parameter [${paramName}] must be at most ${rules.max}.`);
|
|
83
|
+
}
|
|
84
|
+
} else if (rules.type === 'string') {
|
|
85
|
+
if (typeof value !== 'string') {
|
|
86
|
+
errors.push(`Parameter [${paramName}] must be a string.`);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Length validation for strings
|
|
91
|
+
if (rules.minLength !== undefined && value.length < rules.minLength) {
|
|
92
|
+
errors.push(`Parameter [${paramName}] must be at least ${rules.minLength} characters.`);
|
|
93
|
+
}
|
|
94
|
+
if (rules.maxLength !== undefined && value.length > rules.maxLength) {
|
|
95
|
+
errors.push(`Parameter [${paramName}] must be at most ${rules.maxLength} characters.`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Format validation
|
|
99
|
+
if (rules.format) {
|
|
100
|
+
const formatPatterns = {
|
|
101
|
+
'email': /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
102
|
+
'url': /^https?:\/\/.+/i,
|
|
103
|
+
'ip': /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/,
|
|
104
|
+
'date': /^\d{4}-\d{2}-\d{2}$/,
|
|
105
|
+
'hexColor': /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
if (formatPatterns[rules.format] && !formatPatterns[rules.format].test(value)) {
|
|
109
|
+
errors.push(`Parameter [${paramName}] must be a valid ${rules.format}.`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} else if (rules.type === 'boolean') {
|
|
113
|
+
if (typeof value !== 'boolean' && value !== 'true' && value !== 'false') {
|
|
114
|
+
errors.push(`Parameter [${paramName}] must be a boolean.`);
|
|
115
|
+
}
|
|
116
|
+
} else if (rules.type === 'array') {
|
|
117
|
+
if (!Array.isArray(value)) {
|
|
118
|
+
errors.push(`Parameter [${paramName}] must be an array.`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Enum validation
|
|
123
|
+
if (rules.enum && Array.isArray(rules.enum)) {
|
|
124
|
+
if (!rules.enum.includes(value)) {
|
|
125
|
+
errors.push(`Parameter [${paramName}] must be one of: ${rules.enum.join(', ')}.`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (errors.length > 0) {
|
|
131
|
+
throw new Error(`Validation failed: ${errors.join(' ')} See documentation: https://docs.apiverve.com/ref/earnings`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async execute(query, callback) {
|
|
136
|
+
// Handle different argument patterns
|
|
137
|
+
if(arguments.length === 0) {
|
|
138
|
+
// execute() - no args
|
|
139
|
+
query = {};
|
|
140
|
+
callback = null;
|
|
141
|
+
} else if(arguments.length === 1) {
|
|
142
|
+
if (typeof query === 'function') {
|
|
143
|
+
// execute(callback)
|
|
144
|
+
callback = query;
|
|
145
|
+
query = {};
|
|
146
|
+
} else {
|
|
147
|
+
// execute(query)
|
|
148
|
+
callback = null;
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
// execute(query, callback)
|
|
152
|
+
if (!query || typeof query !== 'object') {
|
|
153
|
+
throw new Error('Query parameters must be provided as an object.');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Validate parameters against schema rules
|
|
158
|
+
this.validateParams(query);
|
|
159
|
+
|
|
160
|
+
const method = 'GET';
|
|
161
|
+
const url = method === 'POST' ? this.baseURL : this.constructURL(query);
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
const response = await axios({
|
|
165
|
+
method,
|
|
166
|
+
url,
|
|
167
|
+
headers: {
|
|
168
|
+
'Content-Type': 'application/json',
|
|
169
|
+
'x-api-key': this.APIKey,
|
|
170
|
+
'auth-mode': 'npm-package'
|
|
171
|
+
},
|
|
172
|
+
data: method === 'POST' ? query : undefined
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const data = response.data;
|
|
176
|
+
if (callback) callback(null, data);
|
|
177
|
+
return data;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
let apiError;
|
|
180
|
+
|
|
181
|
+
if (error.response && error.response.data) {
|
|
182
|
+
apiError = error.response.data;
|
|
183
|
+
} else if (error.message) {
|
|
184
|
+
apiError = { error: error.message, status: 'error' };
|
|
185
|
+
} else {
|
|
186
|
+
apiError = { error: 'An unknown error occurred', status: 'error' };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (callback) {
|
|
190
|
+
callback(apiError, null);
|
|
191
|
+
return; // Don't throw if callback is provided
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
throw apiError;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
constructURL(query) {
|
|
199
|
+
let url = this.baseURL;
|
|
200
|
+
|
|
201
|
+
if(query && typeof query === 'object')
|
|
202
|
+
{
|
|
203
|
+
if (Object.keys(query).length > 0) {
|
|
204
|
+
const queryString = Object.keys(query)
|
|
205
|
+
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
|
|
206
|
+
.join('&');
|
|
207
|
+
url += `?${queryString}`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return url;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
module.exports = earningsWrapper;
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apiverve/earnings",
|
|
3
|
+
"version": "1.1.13",
|
|
4
|
+
"description": "Earnings Report is a tool for retrieving company financial data including income statement, balance sheet, and cash flow data from SEC filings. It supports lookup by ticker or CIK with optional year and quarter filters.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=14.0.0"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"index.js",
|
|
13
|
+
"index.d.ts",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "mocha",
|
|
18
|
+
"example": "node examples/basic.js"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/apiverve/earnings-api.git",
|
|
23
|
+
"directory": "npm"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
""
|
|
27
|
+
],
|
|
28
|
+
"author": {
|
|
29
|
+
"name": "APIVerve",
|
|
30
|
+
"email": "hello@apiverve.com",
|
|
31
|
+
"url": "https://apiverve.com"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/apiverve/earnings-api/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://apiverve.com/marketplace/earnings?utm_source=npm&utm_medium=homepage",
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"mocha": "^11.0.1",
|
|
40
|
+
"chai": "^5.1.2",
|
|
41
|
+
"dotenv": "^16.4.7"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"node-fetch": "^3.3.2",
|
|
45
|
+
"promise": "^8.3.0",
|
|
46
|
+
"axios": "1.13.2"
|
|
47
|
+
}
|
|
48
|
+
}
|