A WebSocket provides a long-lived connection for exchanging messages between client and server. Messages may flow in either direction for full-duplex communication. Commandline access is possible with
When to use it: Popular among Bitcoin APIs, WebSockets are great for allowing low-latency tuning of the data to be sent over it (as opposed to HTTP streaming, where a new TCP connection would be needed for each change). Browsers also don’t enforce a connection limit on WebSockets, so they work better for browser apps that use many tabs and communicate with the same domain.
Caveats: While WebSockets as a technology is not exactly new, it is still relatively new in the context of APIs. Also, there is no standard support in WebSocket messages for the things we love about HTTP such as status codes and headers. WebSockets are a great addition to a realtime API, but they should probably not be the sole access mechanism.