How to use Youtube API from Power Query – Part 3a (Mini Post)

Unfortunately, I’m not able to produce a full blog post today.  However, I’ve had a number of people requesting information regarding how to get statistics for multiple Youtube videos at once.

The basic principle is to send a list of video ids to the Youtube API separated by commas.

Below I have produced some “M” code that combines the output of my two previous blog posts.  That is, it –

1) Looks for the top 50 most popular videos
2) Produces a list of the video ids for these videos
3) Requests the statistics for these videos
4) Combines the original table with the statistics

I will do a full detailed walkthrough of how to produce this code in a future post.  But, if you’re feeling adventurous, create a Blank Query and copy and paste the below into the Advanced Editor.  You will need to copy your API key into two locations in the code.

With any luck, you should end up with output looking similar to this:

2016-05-15 12_29_03-youtube v2.xlsx - Excel

Let me know how you go. And if you have any issues don’t hesitate to ask.

I’ll try to get a full blog post up on this as soon as I can.

1 thought on “How to use Youtube API from Power Query – Part 3a (Mini Post)”

  1. Hi Ken,

    I didn’t know you could load two queries in one, that is a fabulous trick!

    I had one query with the videos id and then I tried to use parameters to insert the video ids, comma separated, but it “broke” the query to the google api for some reason….
    Here is the method I used: https://www.youtube.com/watch?v=ip0GSuruQqA

    You do basically the same here right?
    videostring = Text.RemoveRange(List.Accumulate(videoId, “”, (state,current) => state & “,” & current),0,1),
    You create a list of all the video ids separed by comma and then add that to the next query. I would love to know why my method didn’t work, is it because it returns a table instead of a list? Mmmm, I have to try, but your method is more elegant either way.

    It’s time to buy your M book :) !

    Thanks for the blog post! /Ruth

Leave a Reply

Your email address will not be published. Required fields are marked *