title: Accessing API via WebSockets using Python
body: <p>Hobby coder here working on a weekend project.</p>
  
  <p>I wish to access a publicly available API as present here: <a href="https://api.coinsecure.in/" rel="noreferrer">https://api.coinsecure.in/</a>
  It provides us with BitCoin trade data - the API is via websockets which i am not familiar with.</p>
  
  <p>The Websocket URI is wss://coinsecure.in/websocket
  And the method i wished to test is : {"method": "recentbuytrades"}</p>
  
  <p>I am able to access the WebScocket API using the "websocket-client" in Python as listed here: <a href="https://pypi.python.org/pypi/websocket-client/" rel="noreferrer">https://pypi.python.org/pypi/websocket-client/</a></p>
  
  <p>But unfortunately I am unable to figure out how to retrieve the data for the particular method - {"method": "recentbuytrades"}</p>
  
  <p>Would be very grateful for any guidance that you could provide on extracting the data for this particular method.</p>
  
  <p>Best,
  Ryan</p>
  
  <p>[EDIT] 
  Current code I am using is this:</p>
  
  <pre><code>from websocket import create_connection
  ws = create_connection("wss://coinsecure.in/websocket")
  result =  ws.recv()
  print ("Received '%s'" % result)
  ws.close()
  </code></pre>