Skip to main content

No project description provided

Project description

garf for YouTube Reporting API

PyPI Downloads PyPI

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

Prerequisites

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 YT_CLIENT_ID=
export YT_CLIENT_SECRET=
export YT_REFRESH_TOKEN=

Installation

pip install garf-youtube-reporting-api

Usage

Run as a library

from garf_youtube_data_api import report_fetcher
from garf_io import writer


# Specify query
query = """
  SELECT
    dimensions.day AS date,
    metrics.views AS views
  FROM channel
  WHERE
    channel==MINE
    AND startDate = 2010-01-01
    AND endDate = 2024-01-01
  """

# Fetch report
fetched_report = report_fetcher.YouTubeReportingApiReportFetcher().fetch(query)

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

Run via CLI

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

garf <PATH_TO_QUERIES> --source youtube-reporting-api \
  --output <OUTPUT_TYPE> \

where:

  • <PATH_TO_QUERIES> - local or remove files containing queries
  • <OUTPUT_TYPE> - output supported by garf-io library.

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_reporting_api-0.0.1.tar.gz (4.2 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_reporting_api-0.0.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file garf_youtube_reporting_api-0.0.1.tar.gz.

File metadata

File hashes

Hashes for garf_youtube_reporting_api-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a89764a5efb3487363278d180d3331189171d975cb027cc2fc09483343fe5bf2
MD5 c91bb2be55a68707b0e57fce69ae08d6
BLAKE2b-256 1f851135c4c4b2357b596e2cca32c377621e41460dfe0efeaf49499ac8ae429c

See more details on using hashes here.

File details

Details for the file garf_youtube_reporting_api-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for garf_youtube_reporting_api-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cccb706a80246d18ef6acfb14d129f5c92637321845c639b51891eb7fa9dfa3b
MD5 0e9c35186aedfe8d9a6b8cc988c35a04
BLAKE2b-256 7f773906d41529b53824bb4c7135a3c45c28aad0c9ac6147aa200ac836aee5e3

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