C
C#3mo ago
clover

Using SSE and Rest together

I’m developing a web application using ASP.NET for the backend and React for the frontend. I’ve learned that while REST APIs typically require polling for regular updates from the server, Server-Sent Events (SSE) offer a way to handle real-time updates. Would it be reasonable to use REST API calls for standard client-server interactions and SSE for global server updates? I’m considering this approach but am aware that using two different communication methods might seem unusual. It’s also worth noting that I don’t expect the client to receive a lot of asynchronous data.
4 Replies
Marvin
Marvin3mo ago
its all fine using rest api and sse in your project. if you ever consider that the client/server needs more than SSE meaning bi directional communication, i personally would dip SSE and go for websockets from the start.
Pobiega
Pobiega3mo ago
Id say its extremely common to mix SSE with normal API calls
clover
cloverOP3mo ago
Thank you. For my project, bidirectional communication isn’t necessary. It’s a simple application that fetches data from the server and occasionally requires the server to push events. There’s no need for features like chat that would require bidirectional communication. I was just confused becaus i couldnt really find alot of information on the internet for using sse and rest together or maybe i didnt do enough research
Pobiega
Pobiega3mo ago
There is no information to find, because they dont really intersect. Your SSE stuff is on its own endpoint, your rest API endpoints are on theirs you can easily implement both types of endpoints in a single ASP.NET application, with very few lines of code
Want results from more Discord servers?
Add your server