Pull Data From The Web & Display In Home Assistant – Working with APIs – Display YouTube Sub Count

Here is the sensors.yaml entries I mentioned in the video. Just replace the YouTube ID and the YouTube API and you are good to go.

- platform: rest
  resource: https://youtube.googleapis.com/youtube/v3/channels?part=statistics&id=[[YOUTUBEID]]&key=[[APIKEY]]
  method: GET
  value_template: '{{ (value_json["items"][0].statistics.viewCount | int) }}'
  name: "YouTube Views"
  scan_interval: 900

- platform: rest
  resource: https://youtube.googleapis.com/youtube/v3/channels?part=statistics&id=[[YOUTUBEID]]&key=[[APIKEY]]
  name: "TSH YouTube Subscribers"
  value_template: '{{ (value_json["items"][0].statistics.subscriberCount | int) }}'
  scan_interval: 900