Skip to main content

Official Stockseyes SDK for Python — real-time Indian stock market (NSE/BSE) quotes, instrument search, and market data via RapidAPI.

Project description

stockseyes

Official Stockseyes SDK for Python — real-time Indian stock market (NSE/BSE) quotes, instrument search, and market data, served through the Stockseyes APIs on RapidAPI.

Zero runtime dependencies. Uses only Python's built-in urllib. Ships with inline type annotations (PEP 561).

Install

pip install stockseyes

Requires Python ≥ 3.10.

Quickstart

from stockseyes import use_stockeyes, StockEyesConfig

client = use_stockeyes(StockEyesConfig(api_key="your-rapidapi-key"))

quote = client.quote("RELIANCE")
print(f"{quote.symbol}{quote.price}  ({quote.change_percent:.2f}%)")

Getting an API key

  1. Subscribe to the Stockseyes API on RapidAPI.
  2. Copy your X-RapidAPI-Key from the RapidAPI dashboard.
  3. Pass it to StockEyesConfig(api_key=...).

⚠️ Keep your key server-side

Your RapidAPI key is a secret. Never expose it in client-side or public code.

  • Do: use this SDK in a backend service / API route / script.
  • If you must call from the browser: put a proxy in front of RapidAPI and point the SDK at it with the base_url option.

API

use_stockeyes(config) → StockEyesClient

Config Type Default Description
api_key str Required. Your RapidAPI key (x-rapidapi-key).
host str | None Stockseyes RapidAPI host Bare RapidAPI host (x-rapidapi-host).
base_url str | None https://<host>/v1 Override the request base URL (e.g. to point at your proxy).
timeout_s float 10.0 Per-request timeout in seconds.

client.quote(symbol, exchange="NSE") → Quote

q = client.quote("TCS", "NSE")
# Quote(symbol, name, price, change, change_percent, open, high, low,
#       volume, market_cap, timestamp, currency, exchange)

client.batch_quote(symbols, exchange="NSE") → dict

Fetches many quotes sequentially; per-symbol failures are returned, not raised.

batch = client.batch_quote(["RELIANCE", "TCS", "INFY"])
for symbol, data in batch.items():
    if isinstance(data, dict) and "error" in data:
        print(f"{symbol}: {data['error']}")
    else:
        print(f"{symbol}: ₹{data.price}")

client.search(term, options=None) → SearchResult

results = client.search("REL", SearchOptions(limit=10, offset=0))
for i in results.results:
    print(f"{i.symbol}{i.name}")

Error handling

Every failed request raises a typed StockEyesError so you can react programmatically:

from stockseyes import use_stockeyes, StockEyesError, is_stockeyes_error

try:
    quote = client.quote("RELIANCE")
except StockEyesError as err:
    match err.code:
        case "rate_limit":  ...  # back off (HTTP 429)
        case "auth":        ...  # bad/expired key (401/403)
        case "not_found":   ...  # unknown symbol (404)
        case "timeout":     ...  # exceeded timeout_s
        case "network":     ...  # connection failed
        case _:             ...  # other HTTP error — see err.status

StockEyesError exposes code ('rate_limit' | 'auth' | 'not_found' | 'http' | 'network' | 'timeout') and status (HTTP status, or 0 for network/timeout).

Development

cd python
pip install -e ".[dev]"
pytest -v

License

MIT © Tushar Singhal

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

stockseyes-0.2.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

stockseyes-0.2.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for stockseyes-0.2.0.tar.gz
Algorithm Hash digest
SHA256 20f7e411466da795b032b036c6928e797e9c56fdad118eab878c4b25aa5cc641
MD5 3828798a5153f3ef29cc3bc121270103
BLAKE2b-256 1aa5c99c5938190bb61bb9079867de6846404b478ec644ad2abae7ebe7f83c71

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stockseyes-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for stockseyes-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cac393796838256db8f9781b7046d6a2c5cb8b19cd8ad946d1222c16ce9f0982
MD5 c776f6ecb7e382a4461b0946ba3a0bb9
BLAKE2b-256 ba5d3e240bdbdfe38f5e668e0d98b37009e1fccd2032ee69fe8b0a8056ab4320

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