Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
DrewSmith
Helper III
Helper III

Pagination of Shopify API

Hi, 

I've built out my Shopify API and can connect to it in Power BI and Postman. Via Postman I can see the next URL in the response header which I undersand is what's needed for pagination. 

I've worked with pagination in Power BI using ListGenerate but that was mainly where we knew the number of pages to be called. 

How can I do this in Power BI when the next URL is included as part of the Response Header from the first call? 
I almost need it to read
First call - next url 1
next url 1 - return url 2
reutnr url 2 - reutrn url 3 etc. 

Has anyone successfully done this? 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @DrewSmith ,

To achieve this in Power BI, you could use the Power Query M language to programmatically follow the pagination links.

Please try below steps:

1. Initial API Call: Start by making an initial API call to fetch the first set of data along with the pagination link from the response headers.


2. Parse Response Headers: Extract the "next URL" from the response headers. This will require parsing the headers to locate the URL for the next page of data.


3. Recursive Function: Create a recursive function in Power Query M that takes the "next URL" as an input, fetches the data, and then calls itself with the new "next URL" found in the response headers of the subsequent call. This function should continue to execute until there is no "next URL" found, indicating the end of the data.

 

Here's a simplified example of how you might start to structure this function in Power Query M:

et
    FetchData = (url as text) as table =>
    let
        Source = Json.Document(Web.Contents(url)),
        Data = Source[data],
        NextUrl = Source[headers][next_url], // Adjust this based on actual header structure
        Output = if NextUrl <> null then Table.Combine({Data, @FetchData(NextUrl)}) else Data
    in
        Output
in
    FetchData("YourInitialShopifyApiUrl")

Note: This is a simplified example. You'll need to adjust the logic to match the specific structure of the Shopify API response and ensure you handle authentication headers if required.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
EugeneLebedev
Helper IV
Helper IV

If you struggle with connecting to Shopify API, there are ready-made solutions for extracting data automatically from Shopify. Here is one of them: https://vidi-corp.com/shopify-power-bi-connector/

Anonymous
Not applicable

Hi @DrewSmith ,

To achieve this in Power BI, you could use the Power Query M language to programmatically follow the pagination links.

Please try below steps:

1. Initial API Call: Start by making an initial API call to fetch the first set of data along with the pagination link from the response headers.


2. Parse Response Headers: Extract the "next URL" from the response headers. This will require parsing the headers to locate the URL for the next page of data.


3. Recursive Function: Create a recursive function in Power Query M that takes the "next URL" as an input, fetches the data, and then calls itself with the new "next URL" found in the response headers of the subsequent call. This function should continue to execute until there is no "next URL" found, indicating the end of the data.

 

Here's a simplified example of how you might start to structure this function in Power Query M:

et
    FetchData = (url as text) as table =>
    let
        Source = Json.Document(Web.Contents(url)),
        Data = Source[data],
        NextUrl = Source[headers][next_url], // Adjust this based on actual header structure
        Output = if NextUrl <> null then Table.Combine({Data, @FetchData(NextUrl)}) else Data
    in
        Output
in
    FetchData("YourInitialShopifyApiUrl")

Note: This is a simplified example. You'll need to adjust the logic to match the specific structure of the Shopify API response and ensure you handle authentication headers if required.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.