Integrations / Use Edgrapi from Python

Use Edgrapi from Python

Edgrapi is a plain REST API that returns JSON. In Python, requests is all you need.

You need a free Edgrapi key for the REST examples: sign up at edgrapi.com/app (50 credits, no card). Keys start with edgr_ and are shown once.

A small client

import os, time, requests

KEY = os.environ["EDGRAPI_KEY"]

def edgrapi(path, **params):
    for attempt in range(4):
        r = requests.get("https://api.edgrapi.com" + path, params=params,
                         headers={"X-API-Key": KEY}, timeout=30)
        if r.status_code == 429:                      # rate limited: wait and retry
            time.sleep(int(r.headers.get("Retry-After", 2)))
            continue
        if r.status_code == 402:                      # out of credits
            raise RuntimeError(r.json().get("detail") or "out of credits")
        r.raise_for_status()
        print("cost:", r.headers.get("X-Credits-Cost"))
        return r.json()
    raise RuntimeError("still rate limited")

print(edgrapi("/v1/company/AAPL")["company"])
print(edgrapi("/v1/congress", limit=5)["trades"][0])

Every response carries X-Credits-Cost, so you can log what each call spent. Failed calls cost nothing, and a lookup with no results costs 1 credit.

More: the SEC EDGAR API in Python and the endpoint reference.

More setup guides

Claude Desktop and claude.ai · Claude Code · Cursor · ChatGPT · Google Sheets · n8n · Zapier · Quickstart

Get your free key