Skip to main content

Python SDK for the Stoxim API — company master, financials, ratios, shareholding, governance, announcements, and more.

Project description

stoxim-api

Official Python SDK for the Stoxim Financial Data API — company master, financials, ratios, shareholding patterns, corporate actions, governance, and announcements for BSE/NSE-listed companies.

Installation

pip install stoxim-api

Requires Python 3.10+.

Quick Start

from stoxim import Client

client = Client(api_key="sk_live_your_key_here")

# ── Company lookup ─────────────────────────────────────────────────────────────
company = client.company.get("INE040A01034")
print(company.name, company.sector)
# HDFC Bank  Financial Services

# ── Search ─────────────────────────────────────────────────────────────────────
results = client.company.search("Bajaj Finance", limit=5)
for c in results.items:
    print(c.isin, c.name)

# ── Financial periods ──────────────────────────────────────────────────────────
periods = client.financials.list("INE040A01034", period_type="annual", limit=5)
for p in periods.items:
    print(p.period_label, p.revenue, p.pat)

# ── Ratios ─────────────────────────────────────────────────────────────────────
ratios = client.ratios.get("INE040A01034", period_type="annual")
for r in ratios:
    print(r.period_label, r.roe, r.gross_margin, r.pe_ratio)

# ── Shareholding pattern ───────────────────────────────────────────────────────
patterns = client.shareholding.list("INE040A01034")
for s in patterns.items:
    print(s.period_end, s.promoter_pct, s.fii_pct)

# ── Corporate actions ──────────────────────────────────────────────────────────
actions = client.corporate_actions.list("INE040A01034", action_type="dividend")
for a in actions.items:
    print(a.ex_date, a.dividend_amount)

# ── Board composition (Starter+ plan) ─────────────────────────────────────────
board = client.governance.board("INE040A01034")
for member in board:
    print(member.name, member.designation)

# ── AGM records ────────────────────────────────────────────────────────────────
agm_records = client.governance.agm("INE040A01034")

# ── Related-party transactions ─────────────────────────────────────────────────
rpts = client.governance.related_party_transactions("INE040A01034")

# ── Announcements ──────────────────────────────────────────────────────────────
announcements = client.announcements.list(
    "INE040A01034",
    category="financials",
    from_date="2024-01-01",
)
for ann in announcements.items:
    print(ann.filing_date, ann.subject)

Pagination

# Paginate through all large-cap companies
for page in client.company.paginate(market_cap_category="large"):
    for company in page:
        print(company.isin, company.name)

Context Manager

with Client(api_key="sk_live_...") as client:
    company = client.company.get("INE040A01034")
# Connection is closed automatically

Error Handling

from stoxim import (
    AuthenticationError,
    NotFoundError,
    PlanRestrictionError,
    RateLimitError,
    InvalidParameterError,
    ApiError,
)

try:
    company = client.company.get("INVALID_ISIN")
except NotFoundError as e:
    print(f"Not found: {e.message}")
except PlanRestrictionError:
    print("Upgrade your plan to access this endpoint")
except RateLimitError as e:
    print(f"Rate limited — retry after {e.retry_after}s")
except AuthenticationError:
    print("Invalid API key")
except ApiError as e:
    print(f"Unexpected error [{e.error_code}]: {e.message}")

Configuration

client = Client(
    api_key="sk_live_...",
    timeout=60,          # seconds (default: 30)
    max_retries=5,       # includes initial attempt (default: 3)
    retry_on_429=True,   # respect Retry-After header on 429 (default: True)
)

Development

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Lint + format
ruff check src/ tests/
ruff format src/ tests/

# Build
pip install build
python -m build
twine check dist/*

License

MIT — see LICENSE.

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

stoxim_api-1.0.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

stoxim_api-1.0.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file stoxim_api-1.0.0.tar.gz.

File metadata

  • Download URL: stoxim_api-1.0.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for stoxim_api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a946f18ca000382cfc369dc627b82686a8c072c2ccf6fda1a4edc48d469e829e
MD5 380ef6f2ebc6ca8debc111c4aa428c13
BLAKE2b-256 49fef32f9b89a9b4736c1af4c95b3e30ff51cb5ea4dbb359a185b64eaccc2693

See more details on using hashes here.

File details

Details for the file stoxim_api-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: stoxim_api-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for stoxim_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d1e7941bbbb2c0f23fdfd2a21357e0f621466d801493c0386009808e23fbbe5
MD5 9cac08796c462fae00f6dea57725bc90
BLAKE2b-256 1dda384e3ff2e0c91273c1efefcbcf73af199a05a19c630479333017ea6518dc

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