const apiKey = process.env.SECAPI_API_KEY;
if (!apiKey) throw new Error("SECAPI_API_KEY is required");
for (const filingYear of [2023, 2024, 2025]) {
const query = new URLSearchParams({
q: "artificial intelligence regulatory risk",
ticker: "NVDA",
form: "10-K",
filing_year: String(filingYear),
mode: "hybrid",
view: "agent",
limit: "5",
});
const response = await fetch(`https://api.secapi.ai/v1/search/semantic?${query}`, {
headers: { "x-api-key": apiKey },
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const payload = await response.json();
console.log(JSON.stringify({
filingYear,
query: payload.query,
mode: payload.mode,
citations: (payload.sections?.data ?? []).map(({ accession, source_url, section_key, char_start, char_end, highlighted_snippet }) =>
({ accession, source_url, section_key, char_start, char_end, highlighted_snippet })),
requestId: payload.requestId,
traceparent: payload.traceparent,
}, null, 2));
}