Fix NSE API: use GET instead of POST, fix cookie URL#13
Open
unn-Known1 wants to merge 1 commit into
Open
Conversation
- _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=)
There was a problem hiding this comment.
1 issue found across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Owner
|
it keeps changing every now and then. but sure will test it out and approve the PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fromwww.nseindia.com(returns 403) tocharting.nseindia.com_fetch_historical: Changed fromsession.post(url, json=payload)tosession.get(url, params=payload)- POST was returning{"data":[]}search: Changed fromsession.post(url, json=payload)tosession.get(url, params=payload)- POST was ignoring the segment filter, always returning indicessample_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.
Written for commit 1b52413. Summary will update on new commits.
Review in cubic