Giter VIP home page Giter VIP logo

Comments (12)

shalabhgoel13 avatar shalabhgoel13 commented on June 16, 2024 1

happy to help 👍

from py5paisa.

ba11b0y avatar ba11b0y commented on June 16, 2024

Please check https://www.5paisa.com/developerapi/websocketformarketfeeds

from py5paisa.

srikanthbojja avatar srikanthbojja commented on June 16, 2024

@rakesh146 did you get this working in your python script?

from py5paisa.

shalabhgoel13 avatar shalabhgoel13 commented on June 16, 2024

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.

shalabhgoel13 avatar shalabhgoel13 commented on June 16, 2024

Can someone please look at the code and tell me what is wrong in the input paramaters??

from py5paisa.

coder-amogh avatar coder-amogh commented on June 16, 2024

Please check https://www.5paisa.com/developerapi/websocketformarketfeeds

Is there any Pythonic way of doing it? Some function or class?

from py5paisa.

coder-amogh avatar coder-amogh commented on June 16, 2024

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.

shalabhgoel13 avatar shalabhgoel13 commented on June 16, 2024

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.

shalabhgoel13 avatar shalabhgoel13 commented on June 16, 2024

Also there will not be a comma in between } and ] for marketfeed. I am not using any and able to fetch data

from py5paisa.

coder-amogh avatar coder-amogh commented on June 16, 2024

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.

coder-amogh avatar coder-amogh commented on June 16, 2024

@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.

salilshukla9 avatar salilshukla9 commented on June 16, 2024

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

Streaming_data

from py5paisa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.