Skip to content

Fix NSE API: use GET instead of POST, fix cookie URL#13

Open
unn-Known1 wants to merge 1 commit into
marketcalls:masterfrom
unn-Known1:master
Open

Fix NSE API: use GET instead of POST, fix cookie URL#13
unn-Known1 wants to merge 1 commit into
marketcalls:masterfrom
unn-Known1:master

Conversation

@unn-Known1

@unn-Known1 unn-Known1 commented May 29, 2026

Copy link
Copy Markdown

Summary

The NSE charting API has changed - POST requests to the historical and search endpoints return empty data or incorrect results. The actual charting website uses GET requests.

Changes

  • _ensure_cookies: Changed from www.nseindia.com (returns 403) to charting.nseindia.com
  • _fetch_historical: Changed from session.post(url, json=payload) to session.get(url, params=payload) - POST was returning {"data":[]}
  • search: Changed from session.post(url, json=payload) to session.get(url, params=payload) - POST was ignoring the segment filter, always returning indices
  • sample_historical.py: Updated deprecated API calls (download(), exchange= parameter had been removed in v0.2.0)

Testing

All endpoints verified working for both indices (NIFTY 50) and equities (RELIANCE-EQ, INFY-EQ, HDFCBANK-EQ) across daily and 5-min intraday timeframes.


Summary by cubic

Fixes the NSE charting integration by switching to GET requests and using the correct cookie domain. Restores working search and historical data for indices and equities.

  • Bug Fixes
    • Set cookies via https://charting.nseindia.com instead of https://www.nseindia.com (403 on the latter).
    • Use GET with query params for search and historical endpoints; POST returned empty data and ignored the segment filter.
    • Update sample_historical.py: remove deprecated download(), replace exchange= with segment=, use symbols like RELIANCE-EQ, and narrow the sample date range.

Written for commit 1b52413. Summary will update on new commits.

Review in cubic

- _ensure_cookies: use charting.nseindia.com (www.nseindia.com returns 403)
- _fetch_historical: use GET with params instead of POST (POST returns empty data)
- search: use GET with params instead of POST (POST ignores segment filter)
- sample_historical.py: update deprecated API calls (download/remove exchange=)

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread openchart/core.py
@marketcalls

Copy link
Copy Markdown
Owner

it keeps changing every now and then. but sure will test it out and approve the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants