# Use the Signal8 API in Python: SEC filings, insider trades and quotes with requests

> Source: <https://dev.to/signal8/use-the-signal8-api-in-python-sec-filings-insider-trades-and-quotes-with-requests-5ec0>
> Published: 2026-12-05 07:39:12+00:00

**Recommendation:** Persist the stream's next_cursor and pass it as since on each poll, and back off using the Retry-After header on 429s while stopping on DAILY_LIMIT_EXCEEDED.
More in the playbook "Running AI in production": <https://wpnews.pro/playbooks/production-ops>

To call the Signal8 API from Python, send a GET request with `requests` to `https://api.signal8.ai/api/v1/public` and your API key in the `X-Api-Key` header. Below: a first request, a small client that waits out 429 rate limits, Form 4 insider trades, and a loop that picks up each new SEC filing once using a cursor.

`sk_live_` (or `sk_test_` for a test key). Signal8 Pro ($29.50/mo or $294/yr, no free trial) includes the REST API, the MCP server and the streams, at 120 requests a minute and 10,000 a day, with up to 3 API keys.`pip install requests`.` SIGNAL8_API_KEY` instead of writing it into the script.
Every response is JSON. Successful ones put the result under `data`; errors put `code` and `message` under `error`.

**Python: get a quote**

``` python
# pip install requests
import os
import requests

r = requests.get(
    "https://api.signal8.ai/api/v1/public/companies/AAPL/quote",
    headers={"X-Api-Key": os.environ["SIGNAL8_API_KEY"]},
    timeout=30,
)
r.raise_for_status()
quote = r.json()["data"]
print(quote["ticker"], quote["currentPrice"], quote["changePercent"])
```

Pro allows 120 requests a minute and 10,000 a day. Past the per-minute limit the API answers 429 `RATE_LIMIT_EXCEEDED` with a `Retry-After` header in seconds; past the daily limit it answers 429 `DAILY_LIMIT_EXCEEDED`, which resets at midnight UTC. The client below sleeps on the first and stops on the second.

**Python: signal8_client.py**

``` python
# signal8_client.py: a small client with rate-limit handling.
import os
import time
import requests

BASE = "https://api.signal8.ai/api/v1/public"
session = requests.Session()
session.headers["X-Api-Key"] = os.environ["SIGNAL8_API_KEY"]

class Signal8Error(Exception):
    pass

def get(path, **params):
    """GET a Signal8 endpoint and return the decoded JSON body."""
    for _ in range(5):
        r = session.get(BASE + path, params=params, timeout=30)
        if r.status_code == 429:
            error = r.json().get("error", {})
            if error.get("code") == "DAILY_LIMIT_EXCEEDED":
                raise Signal8Error(error.get("message"))  # resets at midnight UTC
            time.sleep(int(r.headers.get("Retry-After", "5")))
            continue
        if not r.ok:
            error = r.json().get("error", {})
            raise Signal8Error(f"{r.status_code} {error.get('code')}: {error.get('message')}")
        return r.json()
    raise Signal8Error("still rate limited after 5 tries")
```

Every response also carries `X-RateLimit-Remaining` and `X-DailyLimit-Remaining`, so a batch job can slow down before it hits either limit.

`/intelligence/{ticker}/insider-transactions` returns each Form 4 transaction with the insider, title, date, shares, price and value. `transactionCode=P` keeps open-market purchases; `S` is a sale, `A` an award, `M` an option exercise.

**Python: recent insider purchases**

``` python
from signal8_client import get

page = get("/intelligence/AAPL/insider-transactions", transactionCode="P", limit=20)
for t in page["data"]["transactions"]:
    print(t["transactionDate"][:10], t["insiderName"], t["insiderTitle"],
          t["shares"], "@", t["pricePerShare"])
```

`/stream/events` returns the events of the real-time stream as pages. Keep the `next_cursor` and send it as `since` on the next call to get only what arrived after it. When `has_more` is true, call again straight away. Events are kept for 24 hours.

**Python: a polling loop**

``` python
import time
from pathlib import Path

from signal8_client import get

CURSOR_FILE = Path("signal8-cursor.txt")

def poll_once():
    params = {"channels": "filings", "forms": "8-K,S-1,424B*", "limit": 200}
    if CURSOR_FILE.exists():
        params["since"] = CURSOR_FILE.read_text().strip()
    page = get("/stream/events", **params)["data"]
    for event in page["events"]:
        f = event["data"]
        print(f["accepted_at"], f["form"], f["company"], f["tickers"], f["filing_url"])
    if page["next_cursor"]:
        CURSOR_FILE.write_text(page["next_cursor"])  # save after handling the events
    return page["has_more"]

while True:
    if not poll_once():
        time.sleep(60)
```

Filters match the stream: `tickers`, `ciks`, `forms` (a trailing `*` matches a family), `items` for 8-K items, `market_cap_min` and `market_cap_max` in US dollars, and `channels` (for example `filings`, `filings.ai`, `press_releases` and `press_releases.ai`). A filter on a figure we do not have never matches: an unknown market cap fails a market cap filter.

For filings the moment we see them, without polling, open the WebSocket at `wss://api.signal8.ai/api/v1/stream` with the same key. One key can hold 2 connections at once. The [Python streaming tutorial](https://signal8.ai/developer/streams/stream-sec-filings-python) builds a full alert bot with reconnects and cursor resume, and the [protocol reference](https://signal8.ai/developer/streams/protocol) lists every message.

| Status and code | What it means | 
|---|---|
| 401 `API_KEY_REQUIRED` | No key was sent, or the header value is not a Signal8 key. Send `X-Api-Key: sk_live_...` . | 
| 401 `INVALID_API_KEY` | The key is wrong, revoked, rotated or expired. | 
| 403 `PRO_REQUIRED` | The key's account is on the Free plan. The API is part of Signal8 Pro. | 
| 429 `RATE_LIMIT_EXCEEDED` | Over 120 requests in a minute. Wait for `Retry-After` seconds. | 
| 429 `DAILY_LIMIT_EXCEEDED` | Over 10,000 requests today. Resets at midnight UTC. | 
| 400 `BAD_FILTER` /`BAD_CURSOR` | A stream filter failed validation, or `since` is not a cursor we issued. | 

Each one is covered in [Troubleshooting](https://signal8.ai/developer/troubleshooting).

**Is there a Signal8 Python SDK?**

Yes. `pip install signal8` installs a thin client (Python 3.9 or newer, its only dependency is requests) whose methods return the API JSON unchanged. You do not need it: the API is plain HTTPS and JSON, and the requests examples in this article are a complete client.

**How do I authenticate to the Signal8 API in Python?**

Send your key in the X-Api-Key header, for example requests.get(url, headers={"X-Api-Key": key}). An Authorization: Bearer header with the key also works.

**How many requests can my Python script make?**

Signal8 Pro allows 120 requests a minute and 10,000 a day, with up to 3 API keys. Responses that served nothing (400, 404 or a 5xx) give their daily count back, up to a cap.

The original guide, kept up to date, is on Signal8: [signal8.ai/integrations/python](https://signal8.ai/integrations/python).
