Introducing the Batch API

api

#1

We’re excited to announce a new feature of the Asana platform! We have just added an endpoint that will let you perform an entire batch of work in parallel using just a single HTTP request. For example, in just one request you can now:

  • Fetch several individual tasks
  • Update a task, add it to a project, and add followers
  • Add multiple users to a team

This all happens in parallel on our servers, so you can accomplish more in less time without having to perform any client-side parallelization.

You can read all about the batch API and see an example in the documentation. Please let us know what you think!


#2

How cool is that @Joe_Trollo? Great work Asanas <3


#8

@Joe_Trollo thanks :+1: Is there a way to create multiple tasks in one call WITH a guarantee on the order?


#9

The batch API won’t guarantee the order in which the actions are executed. Creating tasks in a particular order requires waiting for one task to be created before trying to create the next one, which would almost entirely counteract the benefits gained from using the batch API.

However, with a clever combination of creating tasks and ordering them, it is still possible to create tasks more quickly with the batch API and still have them be in a particular desired order. Knowing that the maximum batch size is 10, suppose you have 50 tasks to create. Create every 50/10 = 5th task through the normal POST /tasks endpoint, leaving the project with tasks 1, 6, 11, 16, … 46 in the correct order.

Once those first tasks are created, make a batch request to create tasks 2, 7, 12, 17, …, 47. These will be out-of-order at the end of the project. Then make a second batch request that calls POST /tasks/task-id/addProject on each of the tasks created in the first batch request, using the insert_after parameter to put them in the correct place (task 2 goes after task 1, task 7 goes after task 6, …). After this second batch request, the project will have tasks 1, 2, 6, 7, 11, 12, …, 46, 47 in the correct order. With two requests, 10 tasks have been created in the correct location, which means tasks are still created five times faster than they could have been created through the normal endpoint.

You can repeat this process for tasks 3, 8, 13, …, 48 and so on until all tasks have been created.


#10

wow that promise to be one challenging algorithm :stuck_out_tongue: thanks for the tip!
With Templana, I am creating a lot of tasks, and that would really help to be able to bulk create tasks…