const apiKey = process.env.SECAPI_API_KEY;
if (!apiKey) throw new Error("SECAPI_API_KEY is required");
const query = new URLSearchParams({
ticker: "JPM",
forms: "4",
transaction_code: "P",
date_from: "2025-01-01",
limit: "50",
view: "agent",
});
const response = await fetch(`https://api.secapi.ai/v1/insiders?${query}`, {
headers: { "x-api-key": apiKey },
});
if (!response.ok) throw new Error(`SEC API ${response.status}: ${await response.text()}`);
const payload = await response.json();
console.log(JSON.stringify({
hasMore: payload.hasMore,
nextCursor: payload.nextCursor,
reviewQueue: (payload.data ?? []).map((trade) => ({
ownerName: trade.ownerName,
ownerTitle: trade.ownerTitle,
filingDate: trade.filingDate,
transactionDate: trade.transactionDate,
transactionCode: trade.transactionCode,
securityTitle: trade.securityTitle,
shares: trade.transactionShares,
price: trade.transactionPrice,
value: trade.transactionValue,
accessionNumber: trade.accessionNumber,
filingUrl: trade.filingUrl ?? null,
})),
requestId: payload.requestId,
}, null, 2));