DEV Community

Cover image for Pull Real-Time SEC Filings and Stock Data in Python (and Analyze It With AI!)
Ada from CoinAPI
Ada from CoinAPI

Posted on

Pull Real-Time SEC Filings and Stock Data in Python (and Analyze It With AI!)

Ever wanted to get real-time stock prices or fresh SEC filings straight into your Python scripts, without fighting CSVs or ugly web scraping? Let’s do it together, step by step, using FinFeedAPI (via API Bricks) and some AI magic!

What You’ll Build

  • A Python script (or notebook) that fetches live SEC filings and stock info for any ticker
  • The ability to summarize those filings using Anthropic’s Claude AI
  • A simple foundation for dashboards, alerts, or research tools

Sample output:

Title: 10-K | Date: 2025-03-01
Title: 8-K | Date: 2025-02-15
Summary: "This 10-K filing details Apple's annual financial results, with significant growth in revenue and R&D investments..."
Enter fullscreen mode Exit fullscreen mode

Prerequisites

  • Python 3.8+
  • API key from FinFeedAPI SEC & Stock MCP (free to start)
  • Basic Python skills
  • (Optional) Anthropic API key if you want AI-powered summaries

1. Install Your Tools

Fire up your terminal and run:

pip install api-bricks-sdk anthropic
Enter fullscreen mode Exit fullscreen mode

💡 You only need anthropic if you want to add the AI summary step!

2. Grab Your API Key

Go to apibricks.dev and sign up.

Create a project and copy your API key somewhere safe.

(Optional) Grab an Anthropic API key for LLM summaries.

3. Set Up the API Bricks SDK

Let’s connect to the FinFeedAPI and fetch some data.

from apibricks_sdk import FinFeedApiSecAndStockMcpApi

api_key = "YOUR_API_KEY"  # paste your API key here
client = FinFeedApiSecAndStockMcpApi(api_key)
Enter fullscreen mode Exit fullscreen mode

4. Fetch Stock Data (The Fun Begins!)

Let’s pull live data for Apple (AAPL):

symbol_info = client.symbols_symbol_get(symbol='AAPL')
print(symbol_info)
Enter fullscreen mode Exit fullscreen mode

Output:

{'symbol': 'AAPL', 'name': 'Apple Inc.', ...}
Enter fullscreen mode Exit fullscreen mode

5. Get Recent SEC Filings

Let’s see Apple’s latest filings:

sec_filings = client.sec_filings_filings_get(symbol='AAPL')
for filing in sec_filings['filings'][:5]:
    print(f"Title: {filing['formType']} | Date: {filing['filedAt']}")
Enter fullscreen mode Exit fullscreen mode

Output:

Title: 10-K | Date: 2025-03-01
Title: 8-K | Date: 2025-02-15
...
Enter fullscreen mode Exit fullscreen mode

This is real, live data!

  1. (Optional) Summarize a Filing With Claude AI Ready for some generative AI? Let’s use Anthropic’s Claude to make sense of those filings:
import anthropic

client_anthropic = anthropic.Client(api_key="YOUR_ANTHROPIC_API_KEY")
response = client_anthropic.completions.create(
    prompt=f"Summarize the following SEC filing:\n{sec_filings['filings'][0]['text']}",
    model="claude-3-opus-20240229",
    max_tokens_to_sample=512,
)
print(response.completion)
Enter fullscreen mode Exit fullscreen mode

Output:

"This 10-K filing details Apple's annual financial results, with significant growth in revenue and R&D investments..."
Enter fullscreen mode Exit fullscreen mode

AI-powered analysis, no manual reading required!

  1. Error Handling (Because Stuff Happens) Good code checks for trouble:
try:
    symbol_info = client.symbols_symbol_get(symbol='AAPL')
except Exception as e:
    print("Error fetching symbol info:", e)
Enter fullscreen mode Exit fullscreen mode

What Next? Build Something Cool!

You now have the basics to:

  • Power a dashboard with live company data
  • Build bots that summarize filings for your team
  • Create alerts for new SEC documents

The sky’s the limit. Try plugging in your own tickers, combining with other APIs, or visualizing the data in pandas/matplotlib.

Useful Links

API Bricks SDK GitHub

Let’s Chat!

What would you build with live SEC and stock data? Got questions or project ideas? Drop them in the comments - happy to help!

If you enjoyed this, follow for more practical API builds, fintech tools, and AI tricks.

Top comments (0)