iOS Dummy
iOS Dummy

Reputation: 55

Youtube Data v3 - How do I filter ChannelSections query by targeting

This query:

https://www.googleapis.com/youtube/v3/channelSections?part=snippet%2CcontentDetails%2Ctargeting&channelId=UC-9-kyTW8ZkZNDHQJ6FgpwQ&key={YOUR_API_KEY}

returns lots of data like this:

{
   "kind": "youtube#channelSection",
   "etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/oIyqO89jk-vcfHm5Kuz3sikdUzc\"",
   "id": "UC-9-kyTW8ZkZNDHQJ6FgpwQ.lc3PRFGaA4k",
   "snippet": {
    "type": "singlePlaylist",
    "style": "horizontalRow",
    "channelId": "UC-9-kyTW8ZkZNDHQJ6FgpwQ",
    "position": 0
   },
   "contentDetails": {
    "playlists": [
     "PLFgquLnL59alW3xmYiWRaoz0oM3H17Lth"
    ]
   },
   "targeting": {
    "regions": [
     "US"
    ]
   }
  },

Is there any way to fetch only items with specific region?

Thanks for any help.

Upvotes: 0

Views: 165

Answers (1)

not_a_bot
not_a_bot

Reputation: 2362

You can't filter these channel sections in your query like that. What you'd have to do is get the list of ChannelSections from that channel, store it in an object, and check if the targeted region for each channel section matches what you want (i.e. the value in targeting.regions[] equals XX, where XX is the region you're looking for). Then, you could store the channel sections that you wanted to find into an array and return that. If you're concerned about time, you'd have to set up a server that can do all of that for you.

Upvotes: 1

Related Questions