Browse documentation
SDKs

Python SDK

The official Python SDK for the Drishti API provides a synchronous HTTP client, low-level request methods, and an async websocket client.

Requirements

  • Python 3.10+
  • A valid Drishti API key

Installation

bash
pip install drishti-sdk

Package: drishti-sdk on PyPI.

Quick start

python
from drishti_sdk import DrishtiClient

with DrishtiClient(api_key="YOUR_API_KEY") as client:
    news = client.get_news(
        symbols=["RELIANCE", "TCS"],
        limit=10,
    )
    print(len(news["data"]))

WebSocket session

The websocket client connects automatically on the first subscribe, events, or async with call and keeps retrying after disconnects until the session closes.

Event listeners

python
import asyncio
from drishti_sdk import DrishtiClient

async def main() -> None:
    client = DrishtiClient(api_key="YOUR_API_KEY")
    async with client.websocket(
        reconnect_initial_delay=1.0,
        reconnect_max_delay=30.0,
        on_announcements=lambda announcement: print(
            "announcement", announcement
        ),
    ) as ws:
        await ws.subscribe("announcements", symbols=["RELIANCE"])
        await asyncio.Event().wait()

asyncio.run(main())

Async iterator

python
async with client.websocket() as ws:
    await ws.subscribe("announcements", symbols=["RELIANCE"], detailed=False)
    async for event in ws.events():
        if event.kind == "data":
            print(event.channel, event.data)

Batch jobs

python
from drishti_sdk import DrishtiClient

with DrishtiClient(api_key="YOUR_API_KEY") as client:
    with open("batch.jsonl", "rb") as f:
        file_bytes = f.read()

    job = client.post_batch_jobs_file(
        file_name="batch.jsonl",
        file_bytes=file_bytes,
        display_name="Quarterly run",
    )

Helper surface

API wrappers

FunctionReference
get_news`GET /v1/news`
get_block_deals`GET /v1/block-deals`
get_symbols_metadata`GET /v1/symbols/metadata`
get_announcements_categories`GET /v1/announcements/categories`
get_announcements`GET /v1/announcements`
post_daily_summary`POST /v1/daily-summary/`
get_earnings_index`GET /v1/earnings/index`
get_earnings`GET /v1/earnings`
get_earnings_detail`GET /v1/earnings/detail`
get_earnings_attachments`GET /v1/earnings/attachments`
get_earnings_citation_pdf`GET /v1/earnings/citations/{earnings_id}/pdf`
get_earnings_citation_page`GET /v1/earnings/citations/{earnings_id}/page/{page}`
get_upcoming_earnings`GET /v1/earnings/upcoming`
get_concalls`GET /v1/concalls`
get_concall_citation_pdf`GET /v1/concalls/citations/{concall_id}/pdf`
get_concalls_index`GET /v1/concalls/index`
get_upcoming_concalls`GET /v1/concalls/upcoming`
get_concalls_detail`GET /v1/concalls/detail`
get_concalls_transcript`GET /v1/concalls/transcript`
post_concalls_transcripts`POST /v1/concalls/transcripts`
get_alerts`GET /v1/alerts`
get_account`GET /v1/account`
get_account_limits`GET /v1/account/limits`
get_account_usage`GET /v1/account/usage`
get_account_ledger`GET /v1/account/ledger`
post_batch_jobs`POST /v1/batch/jobs`
post_batch_jobs_file`POST /v1/batch/jobs`
get_batch_jobs`GET /v1/batch/jobs`
get_batch_jobs_job_id`GET /v1/batch/jobs/{job_id}`
delete_batch_jobs_job_id`DELETE /v1/batch/jobs/{job_id}`
get_batch_jobs_job_id_results`GET /v1/batch/jobs/{job_id}/results`

Workflow helpers

FunctionReference
wait_for_batch_job_completionPolls get_batch_jobs_job_id until a terminal job status is reached.
submit_batch_job_and_waitCalls post_batch_jobs_file, then waits for completion.

Transport helpers

FunctionReference
requestAny API route; pass an arbitrary method and path.
request_v1Any /v1/... route; convenience wrapper around request.
getConvenience wrapper over request for GET routes.
postConvenience wrapper over request for POST routes.
putConvenience wrapper over request for PUT routes.
patchConvenience wrapper over request for PATCH routes.
deleteConvenience wrapper over request for DELETE routes.
websocket/docs/guides/websockets