Comments (12)
happy to help 👍
from py5paisa.
Please check https://www.5paisa.com/developerapi/websocketformarketfeeds
from py5paisa.
@rakesh146 did you get this working in your python script?
from py5paisa.
Hi I am trying to fetch marketfeed using the following code in curl.
curl -X POST -H 'content-type: application/json' \ --data '{"head":{"appName": "5P5737xxxx","appVer": "1.0","key": "Yxe8eWGAIL2CoSZX24xl5AgS7rCCxxxx","osName": "WEB","requestCode": "5PMF","userId": "idY45BLxxxx","password": "CxR0vWYxxx"},\ "body": {"Count":1,"MarketFeedData":{"Exch": "N","ExchType": "C","Symbol": "BHEL","Expiry": "","StrikePrice": "0","OptionType": ""},"ClientLoginType": "0","LastRequestTime": "/Date(0)/","RefreshRate": "H"}}' \ https://openapi.5paisa.com/VendorsAPI/Service1.svc/MarketFeed
But I am getting the following error,
{"body":{"CacheTime":5,"Data":null,"Message":"Invalid Input Parameters.","Status":2,"TimeStamp":"/Date(1607484700699+0530)/"},"head":{"responseCode":"5PMF","status":"0","statusDescription":"Success"}}
from py5paisa.
Can someone please look at the code and tell me what is wrong in the input paramaters??
from py5paisa.
Please check https://www.5paisa.com/developerapi/websocketformarketfeeds
Is there any Pythonic way of doing it? Some function or class?
from py5paisa.
I tried this: but I get status code as 400
and
Response as:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Request Error</title>
<style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>
</head>
<body>
<div id="content">
<p class="heading1">Request Error</p>
<p>The server encountered an error processing the request. See server logs for more details.</p>
</div>
</body>
</html>
Code I used:
import requests
url = "https://Openapi.5paisa.com/VendorsAPI/Service1.svc/MarketFeed"
data = {
"head": {
"appName": "5P523xxxxx",
"appVer": "1.0",
"key": "xxxxxxx",
"osName": "WEB",
"requestCode": "5PMF",
"userId": "xxxxxx",
"password": "xxxxxx"
},
"body": {
"Count": 1,
"MarketFeedData": [
{
"Exch": "N",
"ExchType": "C",
"Symbol": "BHEL",
"Expiry": "",
"StrikePrice": "0",
"OptionType": ""
},
],
"ClientLoginType": 0,
"LastRequestTime": "/Date(0)/",
"RefreshRate": "H"
}
}
headers = {
"Content-Type": 'application/json'
}
r = requests.post(url, data = data, headers = headers)
print(r.status_code)
try:
print(r.text)
except Exception as e:
print(f'ERROR: {e}')
from py5paisa.
url = "https://openapi.5paisa.com/VendorsAPI/Service1.svc/MarketFeed"
response = requests.post(url,json=data)
print(response.json())
use this code. No need to set headers to json.
try this, please do tell me if this worked for you or not?
BTW by looking at your code, I got the mistake I was doing and finally am able to fetch data .. Thanks a lot. This is the output
{"body":{"CacheTime":5,"Data":[{"Exch":"N","ExchType":"C","High":37,"LastRate":36.4,"Low":35.75,"PClose":35.65,"TickDt":"/Date(1607673342000+0530)/","Time":26742,"Token":438,"TotalQty":26845468}],"Message":"Success","Status":0,"TimeStamp":"/Date(1607673342000+0530)/"},"head":{"responseCode":"5PMF","status":"0","statusDescription":"Success"}}
from py5paisa.
Also there will not be a comma in between } and ] for marketfeed. I am not using any and able to fetch data
from py5paisa.
try this, please do tell me if this worked for you or not?
Yay! It finally worked, thanks a ton man!
BTW by looking at your code, I got the mistake I was doing and finally am able to fetch data .. Thanks a lot. This is the output
Cool! 👍
from py5paisa.
@shalabhgoel13 Can you please help me with this issue: #33?
The team is not even getting in touch... So we'll all have to figure out ourselves somehow 😞
from py5paisa.
while using "client.Streaming_data(dict1)" I get repetitive live data, but when I want to access the data in any way it always start streaming and no able to access the data of that list coming from server. see the screenshot of code attached
![]() |
---|
from py5paisa.
Related Issues (20)
- TOTP login is not working HOT 1
- Close websocket connection HOT 1
- issue with the same script price HOT 2
- How to get Response Token using code for Login? HOT 2
- getting wrong status for mcx in Market status API
- order updated through websocket HOT 1
- How to reuse the session? HOT 2
- Live feed is not working
- Unable to establish web socket connection for market feed HOT 2
- Automatic authentication HOT 5
- Couldn't read data anymore from the API's
- not able to install liberary on google collab
- not able to install the py5paisa on google collab and AWS sagemaker
- Error while installing latest version using pip HOT 1
- Invalid syntax and deprecated readme
- RemoteOrderID is not being used while placing order on MCX
- Inconsistent behaviour between Tradestation website and API - Cash Orders on NSE generate errors like 'Scrip Not Available for Trading" - but can place order for same scrip on Tradestation website
- Incorrect response for Futures data
- Major Bug: self.payload not being reset
- Lack of Clear API Responses for User Actions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from py5paisa.