Skip to content

lulzasaur9192/sec-edgar-api-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

SEC EDGAR Insider Trading API — Python & JavaScript Examples

RapidAPI Railway

Real-time SEC Form 4 insider trading data. Track when company insiders (CEOs, CFOs, directors, 10% owners) buy or sell stock.

What It Does

  • 613+ insider trades indexed and growing daily
  • Parses SEC EDGAR Form 4 filings automatically
  • Filter by ticker, insider name, transaction type (buy/sell), date range
  • Returns structured JSON with transaction details, share counts, prices, and ownership changes

Quick Start

curl -X GET "https://sec-edgar-insider-alerts.p.rapidapi.com/trades?ticker=AAPL&limit=10" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: sec-edgar-insider-alerts.p.rapidapi.com"

Python Example

import requests

url = "https://sec-edgar-insider-alerts.p.rapidapi.com/trades"

params = {
    "ticker": "AAPL",
    "days": 30,
    "limit": 50
}

headers = {
    "X-RapidAPI-Key": "YOUR_API_KEY",
    "X-RapidAPI-Host": "sec-edgar-insider-alerts.p.rapidapi.com"
}

response = requests.get(url, headers=headers, params=params)
trades = response.json()

for trade in trades.get("trades", []):
    print(f"{trade['filing_date']} | {trade['insider_name']} | "
          f"{trade['transaction_type']} | {trade['shares']:,} shares @ ${trade['price']:.2f}")

Get all insider buys (bullish signal)

params = {
    "ticker": "TSLA",
    "transaction_type": "purchase",
    "days": 90
}

response = requests.get(url, headers=headers, params=params)
buys = response.json()

print(f"Found {len(buys['trades'])} insider purchases for TSLA in last 90 days")
for buy in buys["trades"]:
    print(f"  {buy['insider_name']} ({buy['insider_title']}) bought {buy['shares']:,} shares")

JavaScript / Node.js Example

const axios = require('axios');

const options = {
  method: 'GET',
  url: 'https://sec-edgar-insider-alerts.p.rapidapi.com/trades',
  params: { ticker: 'AAPL', days: 30, limit: 50 },
  headers: {
    'X-RapidAPI-Key': 'YOUR_API_KEY',
    'X-RapidAPI-Host': 'sec-edgar-insider-alerts.p.rapidapi.com'
  }
};

async function getInsiderTrades() {
  const { data } = await axios.request(options);

  console.log(`Found ${data.trades.length} insider trades for AAPL`);

  data.trades.forEach(trade => {
    console.log(`${trade.filing_date} | ${trade.insider_name} | ${trade.transaction_type} | ${trade.shares} shares`);
  });
}

getInsiderTrades();

Monitor multiple tickers

const tickers = ['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'NVDA'];

async function scanInsiderActivity() {
  for (const ticker of tickers) {
    const { data } = await axios.request({
      ...options,
      params: { ticker, days: 7, limit: 10 }
    });

    if (data.trades.length > 0) {
      console.log(`\n${ticker}: ${data.trades.length} insider trades this week`);
      data.trades.forEach(t => console.log(`  ${t.insider_name}: ${t.transaction_type} ${t.shares} shares`));
    }
  }
}

scanInsiderActivity();

Use Cases

  • Algorithmic trading signals — insider buying clusters often precede stock price increases
  • Due diligence — check if insiders are selling before you buy
  • Portfolio monitoring — get alerts when insiders trade in your holdings
  • Research — analyze insider trading patterns across sectors

API Reference

Endpoint Description
GET /trades Get insider trades with filters
GET /trades?ticker=AAPL Filter by stock ticker
GET /trades?days=30 Trades from last N days
GET /trades?transaction_type=purchase Filter buys only
GET /health API health check

Get Your API Key

Subscribe on RapidAPI — free tier available with 50 requests/month.

License

MIT

About

SEC EDGAR API — insider trading data, Form 4 filings, Python & JavaScript examples. Real-time insider buy/sell alerts for any stock ticker.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors