Skip to main content
All CollectionsHow-tosArticlesBuilding blocks
Building blocks - Bulk API Requests
Building blocks - Bulk API Requests

This article is designed to help you understand how to build a flow to handle bulk API requests.

Angela Ruhstorfer avatar
Written by Angela Ruhstorfer
Updated over a week ago

Overview

While working with API platforms, you may need to run multiple values against a single API endpoint. In Tines, you can accomplish this using the explode mode of our event transform action or with our group looping functionality.

Tines references

Before getting started, we recommend familiarizing yourself with the surrounding functionality this article covers:

Make it happen

Scenario: We'll be utilizing the open API, PokéAPI, and its following endpoint: https://pokeapi.co/api/v2/pokemon.

  • First, we want to pull a list of Pokémon using the endpoint that returns an array of names. By default, this endpoint returns 20 results.

  • Then, we want to pull the details of each Pokémon by passing their name in the next request: https://pokeapi.co/api/v2/pokemon/{name}.

  • Lastly, we want to see all of the details pulled for each Pokémon in a single output.

Bulk API requests with explode

In this video, we look at how to approach the "Make it happen" scenario using explodes and implodes.

Written steps:

  1. Create an GET HTTP request action called "Get Pokemon Names" that reaches out to the https://pokeapi.co/api/v2/pokemon endpoint.

  2. Create and connect an event transform action called "Explode Pokemon" set to explode the body.results array of the "Get Pokemon Names" action's output.

  3. Create and connect another GET HTTP request action called "Get Each Pokemon Detail" that reaches out to the endpoint, but with each exploded name appended to the URL in a Value pill from the "Explode Pokemon" action: https://pokeapi.co/api/v2/pokemon/<<explode_pokemon.individual_pokemon.name>>.

  4. Create and connect an event transform action called "Implode Pokemon" set to implode the results of every "Get Each Pokemon Detail" event into one array.

Bulk API requests with group loop

In this video, we look at how to approach the "Make it happen" scenario using group looping.

Written steps:

  1. Create an HTTP request action called "Get Pokemon Names" that reaches out to the https://pokeapi.co/api/v2/pokemon endpoint.

  2. Create and connect a group called "Get Each Pokemon Detail".

  3. For the "Get Pokemon Details" group, click + Option -> add the Loop option.

  4. In the Loop option, set the following in a Value pill: <<MAP(get_pokemon_names.body.results, "name")>>. This uses our MAP function to create an array of Pokémon names that the group loop will iterate through.

  5. Click inside the group. You will see Input and Output tiles.

  6. Within the group, create and connect an HTTP request action between these two tiles called "Get Each Pokemon Detail" that reaches out to the endpoint, but with each name from the group loop input set in step 4 appended to the URL in a Value pill: https://pokeapi.co/api/v2/pokemon/<<input.payload>>.

  7. Configure the Output tile's payload to the results of the "Get Each Pokemon Detail" HTTP action in a Value pill: <<get_pokemon_details.body>>.

Which method should I use?

Both methods have their use cases:

  • Explode → Implode: allows you to see all the events at the root of the story. Exploded events are processed in parallel, not sequentially. This improves performance, but also means that the order of the events that went into the explode may not always be in the same order out of the implode.

  • Group Loop: simplifies the visual look of this flow, reducing the visible event count and action tiles at the root of the story. By default, group loops are processed sequentially. However, we offer the Run loop in parallel option for group loops, which acts the same as the explode-implode behavior.

Take a moment to compare their visual results within the root of the story:

Did this answer your question?