- class ytapi_kit._reporting.ReportingClient(session)[source]
Bases:
object- create_job(*, report_type_id: str, name: str | None = None, on_behalf_of_content_owner: str | None = None) dict[source]
Create a reporting job.
- Parameters:
report_type_id (str) – The type of report this job should create.
name (str, optional) – The name of the reporting job.
on_behalf_of_content_owner (str, optional) – CMS content-owner ID when acting on behalf of a partner account.
- Return type:
pandas.DataFrame
- delete_job(job_id: str, *, on_behalf_of_content_owner: str | None = None) None[source]
Delete an existing Reporting API job.
- Parameters:
job_id (str) – ID of an existing Reporting API job.
on_behalf_of_content_owner (str | None) – CMS content-owner ID when acting on behalf of a partner.
- Returns:
200 or 204 response code is returned by the API.
- Return type:
Returns nothing, but prints message saying the job was successfully deleted if
- download_report(download_url: str) DataFrame[source]
Download a report CSV and (optionally) return a typed DataFrame.
- Parameters:
download_url (str) – HTTPS link from
list_reports().- Return type:
pandas.DataFrame
- get_job(job_id: str, *, on_behalf_of_content_owner: str | None = None) DataFrame[source]
Get an existing Reporting API job.
- Parameters:
job_id (str) – ID of an existing Reporting API job.
on_behalf_of_content_owner (str | None) – CMS content-owner ID when acting on behalf of a partner.
- Returns:
DataFrame with columns
id,name,reportTypeId,createTime,expireTime,systemManaged
- Return type:
pandas.DataFrame
- get_latest_report(identifier: str) DataFrame | bytes[source]
Download the most recent report in a single call.
- Parameters:
identifier (str) –
A reportTypeId (e.g.
"channel_basic_a2"), orA job name returned by
list_jobs()(case-insensitive).
- Returns:
Parsed DataFrame (default) or raw CSV bytes.
- Return type:
pandas.DataFrame | bytes
- get_reports(job_id: str, report_id: str, *, on_behalf_of_content_owner: str | None = None) DataFrame[source]
List metadata for a specific report in a specific job.
- Parameters:
job_id (str) – ID of an existing Reporting API job.
report_id (str) – ID of an existing report within the specific job.
on_behalf_of_content_owner (str | None) – CMS content-owner ID when acting on behalf of a partner.
- Returns:
DataFrame with columns
id,jobId,startTime,endTime,createTime,downloadUrl
- Return type:
pandas.DataFrame
- list_jobs(*, include_system_managed: bool | None = None, page_size: int | None = None, page_token: str | None = None, on_behalf_of_content_owner: str | None = None) tuple[DataFrame, str | None][source]
List existing Reporting API jobs.
- Parameters:
include_system_managed (bool | None, default None) – Include jobs that YouTube has created for you (e.g., system-managed content-owner jobs).
Nonemeans “omit the query param and accept the API default (True).”page_size (int | None) – Max jobs per API call.
page_token (str | None) – Token from a previous call to fetch the next page.
on_behalf_of_content_owner (str | None) – CMS content-owner ID when acting on behalf of a partner.
- Returns:
DataFrame with columns
id,name,reportTypeId,createTime,expireTime,systemManagednext_page_token–Nonewhen there are no more pages.
- Return type:
(pandas.DataFrame, str | None)
- list_report_types(*, include_system_managed: bool | None = None, page_size: int | None = None, page_token: str | None = None, on_behalf_of_content_owner: str | None = None) tuple[DataFrame, str | None][source]
List available report types.
- Parameters:
include_system_managed (bool, optional) – Whether to include YouTube system-managed report types.
page_size (int, optional) – Maximum number of items to return.
page_token (str, optional) – Token for fetching the next page of results.
on_behalf_of_content_owner (str, optional) – CMS content-owner ID when acting on behalf of a partner account.
- Return type:
pandas.DataFrame
- list_reports(job_id: str, *, page_size: int | None = None, page_token: str | None = None, created_after: datetime | str | None = None, on_behalf_of_content_owner: str | None = None) tuple[DataFrame, str | None][source]
List existing reports in a specific job.
- Parameters:
job_id (str) – ID of an existing Reporting API job.
page_size (int | None) – Max jobs per API call.
page_token (str | None) – Token from a previous call to fetch the next page.
created_after (datetime | str | None) – A datetime object or string representing the cutoff date of when reports are created.
on_behalf_of_content_owner (str | None) – CMS content-owner ID when acting on behalf of a partner.
- Returns:
DataFrame with columns
id,jobId,startTime,endTime,createTime,downloadUrlnext_page_token–Nonewhen there are no more pages.
- Return type:
(pandas.DataFrame, str | None)