Python client for the Alpha API (/v1)
Project description
market-stack-sdk (Python)
HTTP client for Alpha API (/v1).
Install
From this directory:
pip install .
Usage
from market_stack_sdk import MarketStackClient
with MarketStackClient(api_key="YOUR_API_KEY") as client:
# Defaults to https://developers.manasija.in
from market_stack_sdk import AnnouncementsQueryParams, DailySummaryRequest, NewsQueryParams
print(client.get_news(NewsQueryParams(symbols=["RELIANCE"], limit=10)))
print(client.get_announcements(AnnouncementsQueryParams(symbols=["RELIANCE"])))
print(
client.get_earnings_detail(
{"symbol": "MEDIASSIST", "quarter": "q4_26", "detailed": True}
)
)
print(
client.post_daily_summary(
{
"body": DailySummaryRequest(
portfolio=[{"symbol": "RELIANCE", "exposure": 10}]
)
}
)
)
All calls automatically send X-API-Key from the provided api_key.
Use get, post, put, patch, delete, or request for any public /v1 endpoint.
WebSocket (/v1/ws)
Requires the websockets package (installed with this SDK).
import asyncio
from market_stack_sdk import MarketStackClient, SubscribeOptions
async def main() -> None:
client = MarketStackClient(api_key="YOUR_API_KEY")
async with client.websocket() as ws:
await ws.subscribe(
SubscribeOptions(product="announcements", symbols=["RELIANCE"], detailed=False)
)
async for event in ws.events():
if event.kind == "subscribed":
print("ready", event.product, event.tier)
elif event.kind == "data":
print(event.channel, event.data.get("symbol"))
asyncio.run(main())
Direct session import (without creating MarketStackClient):
import asyncio
from market_stack_sdk import AlphaWebSocketSession, SubscribeOptions
async def main() -> None:
async with AlphaWebSocketSession(api_key="YOUR_API_KEY", auto_reconnect=True) as ws:
await ws.subscribe(
SubscribeOptions(product="news", symbols=["RELIANCE"], detailed=True)
)
await ws.run()
asyncio.run(main())
Callback style:
async with client.websocket(on_data=lambda e: print(e.data)) as ws:
await ws.subscribe(product="alerts", symbols=["RELIANCE"])
await ws.run()
# Optional resilience hooks:
# async with client.websocket(
# auto_reconnect=True,
# reconnect_initial_delay=1.0,
# reconnect_max_delay=30.0,
# on_reconnect_attempt=lambda attempt, delay, reason: print(attempt, delay, reason),
# on_open=lambda reason: print("connected", reason),
# on_close=lambda reason: print("closed", reason),
# ) as ws:
# ...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file market_stack_sdk-0.2.0.tar.gz.
File metadata
- Download URL: market_stack_sdk-0.2.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
beeae5b72b8bf2794d028fa458ed8207029d6fc08c7788a0854202752e763c07
|
|
| MD5 |
44c80e60aea9d88e595289ef5df42300
|
|
| BLAKE2b-256 |
57bfef8f433d1510982755514a0c9bd74a4c34492fbd2e2c04919b3d644a02b6
|
Provenance
The following attestation bundles were made for market_stack_sdk-0.2.0.tar.gz:
Publisher:
publish-pypi.yml on manasijatech/Market-Stack-SDK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
market_stack_sdk-0.2.0.tar.gz -
Subject digest:
beeae5b72b8bf2794d028fa458ed8207029d6fc08c7788a0854202752e763c07 - Sigstore transparency entry: 1641259230
- Sigstore integration time:
-
Permalink:
manasijatech/Market-Stack-SDK@942cea9eb253d6affa3f245f1ed9a4dbe1238c3b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/manasijatech
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@942cea9eb253d6affa3f245f1ed9a4dbe1238c3b -
Trigger Event:
push
-
Statement type:
File details
Details for the file market_stack_sdk-0.2.0-py3-none-any.whl.
File metadata
- Download URL: market_stack_sdk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4588027d754f9af052edb5789ba3f9cd7874293fdfbd3811f72545ec8ea6947
|
|
| MD5 |
241e854b70a32d8c2a73ff69f73ccc93
|
|
| BLAKE2b-256 |
9fa57f53d9f8b9b6dd3f3bc814900cce6f7fdc8be2a39f459e68c01020bff6b7
|
Provenance
The following attestation bundles were made for market_stack_sdk-0.2.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on manasijatech/Market-Stack-SDK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
market_stack_sdk-0.2.0-py3-none-any.whl -
Subject digest:
e4588027d754f9af052edb5789ba3f9cd7874293fdfbd3811f72545ec8ea6947 - Sigstore transparency entry: 1641259352
- Sigstore integration time:
-
Permalink:
manasijatech/Market-Stack-SDK@942cea9eb253d6affa3f245f1ed9a4dbe1238c3b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/manasijatech
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@942cea9eb253d6affa3f245f1ed9a4dbe1238c3b -
Trigger Event:
push
-
Statement type: