I've been trying to wrap my head around whether REST APIs can be asynchronous or not. I recently watched a video that claimed REST can only function as a synchronous API, but I've come across other sources that suggest the opposite. My understanding is that with REST, you could potentially send a quick response while processing other tasks in the background. Can anyone clarify this for me? Is the video mistaken?
1 Answer
From what I gather, anything that originates from a different server generally requires asynchronous handling. When you make a request to a server and it processes it, you don’t always get immediate data back, especially if it’s handling multiple requests at once. So, yes, it can be asynchronous because the server can handle other processes while waiting for a response.
But that’s a bit misleading. A request can still be synchronous, meaning you wait for the full response before moving on. Asynchronous means you trigger a request and can do other work while waiting for a response. Think about it like placing an order at a restaurant: you can place multiple orders (asynchronous) but still wait for each dish (synchronous) before digging in.