Skip to main content

Garf connector to YouTube APIs

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

garf_youtube-1.0.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

garf_youtube-1.0.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file garf_youtube-1.0.0.tar.gz.

File metadata

  • Download URL: garf_youtube-1.0.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for garf_youtube-1.0.0.tar.gz
Algorithm Hash digest
SHA256 195d247d6fc9437c47e6e646097095af3c25c90d0d7688616b738b6d6cfd28eb
MD5 f406d529d33eaacc4e2266c69ca73411
BLAKE2b-256 e700ab786ec9b16012d299a7bfc0b83234ac78e9d8047231e393c2c146685e32

See more details on using hashes here.

File details

Details for the file garf_youtube-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for garf_youtube-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78b8de1f335d716bb71786904da19a6ae7eb19c863a06116c1cb0e2a6e431bae
MD5 0ae733ef5759fc53300aab5f4bc6bd67
BLAKE2b-256 f3456d9945e8ed12d742076369ca5e89b243792394b2b3f9704142376e8edec1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page