@@ -44,7 +44,8 @@ protected function initialize(): void
44
44
protected function getAuthParams (): array
45
45
{
46
46
return [
47
- 'key ' => $ this ->apiKey
47
+ 'key ' => $ this ->apiKey ,
48
+ 'content ' => 'sec ' // Required parameter
48
49
];
49
50
}
50
51
@@ -119,22 +120,52 @@ private function normalizeFilingData(array $filing): array
119
120
'companyName ' => $ filing ['Company Name ' ] ?? '' ,
120
121
'formType ' => $ filing ['Form ' ] ?? '' ,
121
122
'formDescription ' => $ filing ['Form_Desc ' ] ?? '' ,
123
+ 'formGroup ' => $ filing ['Form_Group ' ] ?? '' , // Added form group
124
+ 'filer ' => $ filing ['Filer ' ] ?? '' , // Added filer
122
125
'filingDate ' => $ date ,
123
126
'reportDate ' => $ date , // Use same date as filing date if report date not provided
124
127
'accessionNumber ' => $ filing ['acc ' ] ?? '' ,
125
128
'fileNumber ' => '' , // Not provided by Kaleidoscope
126
129
'htmlUrl ' => $ filing ['html ' ] ?? '' ,
130
+ 'ixbrlUrl ' => $ filing ['ixbrl ' ] ?? '' , // Added IXBRL URL
127
131
'pdfUrl ' => $ filing ['pdf ' ] ?? '' ,
128
132
'textUrl ' => '' , // Kaleidoscope doesn't provide a direct text URL
129
133
'wordUrl ' => $ filing ['word ' ] ?? '' ,
130
134
'xbrlUrl ' => $ filing ['xbrl ' ] ?? '' ,
131
135
'xlsUrl ' => $ filing ['xls ' ] ?? '' ,
132
136
'ticker ' => $ filing ['ticker ' ] ?? '' ,
133
137
'description ' => $ filing ['Form_Desc ' ] ?? '' ,
134
- 'fiscalYear ' => $ date ? date ('Y ' , strtotime ($ date )) : ''
138
+ 'fiscalYear ' => $ date ? date ('Y ' , strtotime ($ date )) : '' ,
139
+ // Add a documentUrl field using the HTML URL as fallback
140
+ 'documentUrl ' => $ filing ['html ' ] ?? $ filing ['pdf ' ] ?? ''
135
141
];
136
142
}
137
143
144
+ /**
145
+ * Get paginated SEC filings with complete metadata
146
+ *
147
+ * @param string $ticker Stock ticker symbol
148
+ * @param int $limit Maximum number of results to return
149
+ * @param int $offset Pagination offset
150
+ * @return array Array with 'data', 'total', 'start', and 'end' keys
151
+ */
152
+ public function searchFilingsWithPagination (string $ ticker , int $ limit = 10 , int $ offset = 0 ): array
153
+ {
154
+ $ params = [
155
+ 'limit ' => $ limit ,
156
+ 'start ' => $ offset
157
+ ];
158
+
159
+ $ result = $ this ->searchFilings ($ ticker , $ params );
160
+
161
+ return [
162
+ 'data ' => array_map ([$ this , 'normalizeFilingData ' ], $ result ['data ' ] ?? []),
163
+ 'total ' => $ result ['total ' ] ?? 0 ,
164
+ 'start ' => $ result ['start ' ] ?? 0 ,
165
+ 'end ' => $ result ['end ' ] ?? 0
166
+ ];
167
+ }
168
+
138
169
/**
139
170
* Get 10-K reports for a company
140
171
*
@@ -144,8 +175,26 @@ private function normalizeFilingData(array $filing): array
144
175
*/
145
176
public function get10KReports (string $ ticker , int $ limit = 5 ): array
146
177
{
147
- $ filings = $ this ->searchFilings ($ ticker );
148
- return $ this ->filterFilingsByType ($ filings , '10-K ' , $ limit );
178
+ // Using the API's built-in form filtering instead of client-side filtering
179
+ $ params = [
180
+ 'form ' => '10-K ' ,
181
+ 'limit ' => $ limit
182
+ ];
183
+
184
+ try {
185
+ $ response = $ this ->searchFilings ($ ticker , $ params );
186
+ if (empty ($ response ['data ' ])) {
187
+ return [];
188
+ }
189
+
190
+ // Still normalize the data to our expected format
191
+ return array_map ([$ this , 'normalizeFilingData ' ], array_slice ($ response ['data ' ], 0 , $ limit ));
192
+ } catch (\Exception $ e ) {
193
+ if ($ this ->logger ) {
194
+ $ this ->logger ->error ("Failed to fetch 10-K reports: " . $ e ->getMessage ());
195
+ }
196
+ return [];
197
+ }
149
198
}
150
199
151
200
/**
0 commit comments