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.2.0.tar.gz (10.1 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.2.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for form4api-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2aef68f8bf683e77bd67a368ec7ca005307bbc28274e47faf76ff1b3488b5856
MD5 00d7543ce782986398e3345bccc7525b
BLAKE2b-256 303cef1e4da065c278d2f0aaa25e8abbd8bc648b1d59c9e7ee26a3659944b1c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: form4api-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3d4bf3cca573c61e0c9656f22abb385901c304e2eaf630ba0208480eb796aad
MD5 a7b442e0e4425c54869ce6500f7fa8e2
BLAKE2b-256 79f9cf52ea3b00d14e89974de35bf6673ad9634c1c7d345e7565b3821db98ef7

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