WebSockets is a great technology with many applications beyond the front end. I have a feeling that websocket APIs will become far more common in the web ecosphere.

I really like this example of how to interact with a WebSockets api with just-released Lomond 0.1.5.

Get the code from Lomond repos on Github.

This connects to the gdax websocket server and periodically prints the latest BTC price information. If you change the text "ticker" to "level2" it will spew out information on every trade. You could use this as the foundation for algorithmic trading or to keep an eye on your retirement fund (good luck).

Getting Lomond

Lomond is a websocket client library sponsored by Dataplicity. It has a focus on robustness and ease of use.

Lomond runs on Win / Mac / Linux platforms with Python2.7 or Python3*. You can install Lomond with pip:

pip install lomond

If you want to see the above example in action, run the following:

python -m lomond.examples.btcticker
Use Markdown for formatting
*Italic* **Bold** `inline code` Links to [Google](http://www.google.com) > This is a quote > ```python import this ```
your comment will be previewed here
gravatar
Ben

nice

gravatar
Joe

';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//"; alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--

</script>">'><script>alert(String.fromCharCode(88,83,83))</script>

gravatar
Will McGugan

I escape my comments, Joe.

gravatar
Wally Chang

this looks interesting - any chance we get the package on conda?

gravatar
Will McGugan

I think that's probably in the cards. You might want to file an issue to remind me.