#WebDev #API design question: Is there a common way for an HTTP API gateway to report progress for long-running operations? Let’s say a video reencode API call takes 2 minutes to complete. How does a server report progress over time to the client?

Follow

@drahardja
HTTP is a protocol that yields one unique response for each request.

An option is WebRTC, but I don't think anybody sees that as a part the HTTP API world. It would be overkill, anyway.

The best way to do what you ask is to have 2 methods in your API, one for starting the process (returning immediately), and other for getting progress reports. You call the first once, and then the other periodically until it reports 100%. Of course, since any method ends at soon as it returns, you will need a way to run your operation as a separate process in your server; the way to do that is wildly different between different kinds of server.

There are some hacks that can be used if that's not an option, but they are the kind of hacks that make people managing servers really, really hate you.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.