Code Samples

The following lists identify code samples available for the YouTube Analytics API and YouTube Reporting API. You can also download these samples from the youtube/api-samples GitHub repository.

Apps Script

Query reports (YouTube Analytics API)

  1. Export YouTube Analytics data to Google Sheets (reports.query)

Java

Bulk data reports (YouTube Reporting API)

  1. Create a reporting job (reportTypes.list, jobs.create)
  2. Retrieve reports (jobs.list, jobs.reports.list)

Query reports (YouTube Analytics API)

  1. Calling the Analytics API (reports.query)

JavaScript

Query reports (YouTube Analytics API)

  1. Calling the Analytics API (reports.query)

PHP

Bulk data reports (YouTube Reporting API)

  1. Create a reporting job (reportTypes.list, jobs.create)
  2. Retrieve reports (jobs.list, jobs.reports.list)

Python

Bulk data reports (YouTube Reporting API)

  1. Create a reporting job (reportTypes.list, jobs.create)
  2. Retrieve reports (jobs.list, jobs.reports.list)

Query reports (YouTube Analytics API)

  1. Retrieve top 10 videos by view count (reports.query)

Ruby

Query reports (YouTube Analytics API)

  1. Retrieve top 10 videos by view count (reports.query)