can you explain how can i do it with Multiple part...
# ask-ai
h
can you explain how can i do it with Multiple partition routers
k
Certainly! In Airbyte, you can use multiple partition routers to handle cases where you need to iterate over all combinations of multiple partitioning parameters. This is useful when an API requires more than one parameter to fetch different subsets of data (for example, both a list of URLs and a list of strategies). ### How Multiple Partition Routers Work When you configure multiple partition routers on a single stream, Airbyte will generate requests for every possible combination of the partition values from each router. This is essentially a Cartesian product of all partition values. #### Example Suppose you want to fetch data from the Google PageSpeed API, which requires both a
url
and a
strategy
parameter. If you have two URLs (
example.com
,
example.org
) and two strategies (
desktop
,
mobile
), Airbyte will generate the following requests:
Copy code
GET https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=example.com&strategy=desktop GET https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=example.com&strategy=mobile GET https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=example.org&strategy=desktop GET https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=example.org&strategy=mobile
This is achieved by defining two partition routers—one for URLs and one for strategies. Airbyte will iterate over all combinations and make a request for each pair. #### Configuration In the YAML configuration, you would define an array of partition routers under the
partition_router
field. Each router specifies how to inject its partition value into the outgoing request. Here’s a conceptual example:
Copy code
yaml partition_router:   - type: ListPartitionRouter     values:       - "example.com"       - "example.org"     cursor_field: "url"     request_option:       type: RequestOption       field_name: "url"       inject_into: "request_parameter"   - type: ListPartitionRouter     values:       - "desktop"       - "mobile"     cursor_field: "strategy"     request_option:       type: RequestOption       field_name: "strategy"       inject_into: "request_parameter"
With this setup, Airbyte will automatically generate requests for every combination of
url
and
strategy
values. #### Key Points - All combinations: Every possible combination of partition values is requested separately. - Flexible: You can use this approach for any API that requires multiple parameters to partition data. - UI Support: The Connector Builder UI also supports configuring multiple partition routers in the stream configuration section. For more details and examples, see the documentation on [Multiple partition routers](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#partition-router-types) and [Partition Router configuration](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/partition-router) in Airbyte. This approach is consistent across Airbyte versions and is well-documented in the official docs [here](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/partitioning#multiple-partition-routers) and [here](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#partition-router-types).