Skip to main content

garf for YouTube Data API

PyPI Downloads PyPI

garf-youtube-data-api simplifies fetching data from YouTube Data API using SQL-like queries.

Prerequisites

YouTube Data API

  • YouTube Data API enabled.
  • API key to access to access YouTube Data API.

    Once generated expose API key as export GARF_YOUTUBE_DATA_API_KEY=<YOUR_API_KEY>

YouTube Reporting API

  • YouTube Reporting API enabled.

  • Client ID, client secret and refresh token generated. \

    Please note you'll need to use another OAuth2 credentials type - Web application, and set "https://developers.google.com/oauthplayground" as redirect url in it.

  • Refresh token. You can use OAuth Playground to generate refresh token.

    • Select https://www.googleapis.com/auth/yt-analytics.readonly scope
    • Enter OAuth Client ID and OAuth Client secret under Use your own OAuth credentials;
    • Click on Authorize APIs
  • Expose client id, client secret and refresh token as environmental variables:

export GARF_YOUTUBE_REPORTING_API_CLIENT_ID=
export GARF_YOUTUBE_REPORTING_API_CLIENT_SECRET=
export GARF_YOUTUBE_REPORTING_API_REFRESH_TOKEN=

Installation

pip install garf-youtube

Usage

Run as a library

from garf.community.google.youtube import report_fetcher
from garf.io import writer


# Specify query
query = 'SELECT id, snippet.title AS channel_name FROM channels'

# Fetch report
fetched_report = (
  report_fetcher.YouTubeDataApiReportFetcher()
  .fetch(query, id=[<YOUR_CHANNEL_ID_HERE>])
)

# Write report to console
console_writer = writer.create_writer('console')
console_writer.write(fetched_report, 'output')

Learn more on library usage.

Run via CLI

Install garf-executors package to run queries via CLI (pip install garf-executors).

garf <PATH_TO_QUERIES> --source youtube-data-api \
  --output <OUTPUT_TYPE> \
  --source.<SOURCE_PARAMETER=VALUE>

where:

  • <PATH_TO_QUERIES> - local or remove files containing queries
  • <OUTPUT_TYPE> - output supported by garf-io library.
  • <SOURCE_PARAMETER=VALUE - key-value pairs to refine fetching, check available source parameters.

Learn more on CLI usage.

Documentation

You can find a documentation on garf-youtube here.

Samples

Sample queries for interacting with YouTube Data API are located in examples folder.

Metadata

Release files for garf-youtube 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for garf-youtube 1.0.0
File Size Uploaded Provenance Actions
garf_youtube-1.0.0.tar.gz 10.9 kB Without provenance Details for garf_youtube-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for garf-youtube 1.0.0
File Interpreter ABI Platform Actions
garf_youtube-1.0.0-py3-none-any.whl Python 3 none any Details for garf_youtube-1.0.0-py3-none-any.whl

Total release size: 34.2 kB

Release files / garf_youtube-1.0.0.tar.gz

Download URL garf_youtube-1.0.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
195d247d6fc9437c47e6e646097095af3c25c90d0d7688616b738b6d6cfd28eb
BLAKE2b-256 checksum
How to use checksums
e700ab786ec9b16012d299a7bfc0b83234ac78e9d8047231e393c2c146685e32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.4

Release files / garf_youtube-1.0.0-py3-none-any.whl

Download URL garf_youtube-1.0.0-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78b8de1f335d716bb71786904da19a6ae7eb19c863a06116c1cb0e2a6e431bae
BLAKE2b-256 checksum
How to use checksums
f3456d9945e8ed12d742076369ca5e89b243792394b2b3f9704142376e8edec1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.4

Security for garf-youtube 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page