Garf connector to YouTube APIs
Project description
garf for YouTube Data API
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.readonlyscope - Enter OAuth Client ID and OAuth Client secret under Use your own OAuth credentials;
- Click on Authorize APIs
- Select
-
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-executorspackage 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 bygarf-iolibrary.<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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
195d247d6fc9437c47e6e646097095af3c25c90d0d7688616b738b6d6cfd28eb
|
|
| MD5 |
f406d529d33eaacc4e2266c69ca73411
|
|
| BLAKE2b-256 |
e700ab786ec9b16012d299a7bfc0b83234ac78e9d8047231e393c2c146685e32
|
File details
Details for the file garf_youtube-1.0.0-py3-none-any.whl.
File metadata
- Download URL: garf_youtube-1.0.0-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78b8de1f335d716bb71786904da19a6ae7eb19c863a06116c1cb0e2a6e431bae
|
|
| MD5 |
0ae733ef5759fc53300aab5f4bc6bd67
|
|
| BLAKE2b-256 |
f3456d9945e8ed12d742076369ca5e89b243792394b2b3f9704142376e8edec1
|