REST API with websocket using Spring boot

Yes, your Spring application can easily use both WebSocket and REST APIs. If you're going to use Spring Boot, I'd suggest to take a look into their example projects (note the spring-boot-sample-websocket- directories). I think it's the best way to learn.

More on WebSockets, I'd suggest to use STOMP protocol. There is also a nice guide for it on how you can get started.

For your RESTful API, you'll be making simple controllers / services, there is tones of resources for this. You can also follow this guide to get started as well.


While Spring applications support both Websocket and REST API's individually, you can use Websocket connection to send requests to your rest API's too. Needs a little glitching tho, but I've made it work in this github repo. Using this library you can represent your rest-api's in a websocket based protocol.

I also made java (and springboot starter) for client.