Is it OK to "always" use batch endpoint?

Hi everyone, we started using batch endpoint for a few queries, like getting additional data for 1 task (root + subtasks + stories). But, we like it enough, that we may change our code to make the batch, the default endpoint for all our queries.

Is it OK to always use the “/batch”, even if I query only 1 single item?
It will be easier to code instead of having to handle 2 different type of “get”, depending on the length of the query queue.

I haven’t used it myself, but what concern(s) do you have about using it for everything? I can’t offhand see why you couldn’t do that. Maybe you’re wondering if there is any extra overhead?

Exactly, my concerns are about the extra overhead.
But, I think that the overhead, if present, is very low VS the advantages of using the batch for more than 1 query when I can, and that will be, almost every queries. We need to get tasks for 1 or more tags, or projects or user… and most of the time, the batch will be used for more than 1 url.
The client is a web browser, so we call from client-side javascript.

@Joe_Trollo, is there much overhead in the Batch API?

While there is some overhead within our API to turn a single request into multiple requests internally and then to assemble the responses, this is extremely small compared to the overhead of additional network requests (provided that you would be making the requests in serial). For absolute best performance, you would want to make all requests individually and in parallel. If you don’t mind the overall performance being determined by the slowest request in the batch, then using the batch API won’t have any other perceptible impact on performance.

3 Likes