Skip to main content

Python client for the Form4API — real-time SEC Form 4 insider trading data

Project description

form4api

Python client for Form4API — real-time SEC Form 4 insider trading data.

Supports Python 3.11+. Uses httpx for both sync and async HTTP.

Installation

pip install form4api

Sync quickstart

from form4api import Form4ApiClient

client = Form4ApiClient("YOUR_API_KEY")

# Recent open-market purchases at Apple
txns = client.transactions.list(ticker="AAPL", code="P", per_page=5)
for t in txns:
    print(t.insider_name, t.shares_amount, "@", t.price_per_share)

# Company overview
company = client.companies.get("MSFT")
print(company.name, company.active_insiders, "active insiders")

# Insider detail
insider = client.insiders.get("0001234567")
print(insider.name, insider.officer_title)

# Cluster-buy signals (Business plan)
signals = client.signals.list(ticker="NVDA")
for sig in signals:
    if sig.is_cluster_buy:
        print(sig.company_name, sig.insider_count, "buyers")

Async quickstart

import asyncio
from form4api import AsyncForm4ApiClient

async def main():
    async with AsyncForm4ApiClient("YOUR_API_KEY") as client:
        txns = await client.transactions.list(ticker="AAPL", per_page=5)
        for t in txns:
            print(t.insider_name, t.shares_amount, "@", t.price_per_share)

asyncio.run(main())

Resources

Resource Methods
client.transactions .list(**params), .paginate(**params)
client.insiders .search(name, **params), .get(cik), .transactions(cik, **params)
client.companies .get(ticker), .insiders(ticker)
client.signals .list(**params) — Business plan
client.webhooks .create(url, event_types), .list(), .delete(id), .events(**params)

Error handling

from form4api import Form4ApiClient, AuthError, PlanError, RateLimitError, NotFoundError

client = Form4ApiClient("YOUR_API_KEY")

try:
    signals = client.signals.list()
except PlanError as e:
    print(f"Upgrade to {e.required_plan}")
except RateLimitError as e:
    print(f"Retry after {e.retry_after}s")
except AuthError:
    print("Invalid API key")
except NotFoundError:
    print("Resource not found")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

form4api-0.3.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

form4api-0.3.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file form4api-0.3.1.tar.gz.

File metadata

  • Download URL: form4api-0.3.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for form4api-0.3.1.tar.gz
Algorithm Hash digest
SHA256 d10a5b043695b0a85b15bef0d350f23afc74695d0fea5ff79a62c6ae1bd42372
MD5 7e67612dc5a9f034b0372301e88c9b93
BLAKE2b-256 5646489dbb6b4efa6a154cfdb40b3b9b7ee3921bfc4a25e436fbf8dfd27cb6fa

See more details on using hashes here.

File details

Details for the file form4api-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: form4api-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for form4api-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4193a345728a2cc8c365678cc3a3c860a7108755230ccc289cfd107e319e6bc9
MD5 ab6bfa14c8703751a57a3a1fd15b5791
BLAKE2b-256 e0a04e095a9a1dc1915d1616f386b23e471301964185c5ced22e45b625eaef24

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page