Skip to content

Instantly share code, notes, and snippets.

@aik0aaac
Created May 31, 2023 15:06
Show Gist options
  • Save aik0aaac/550fdd9391c8b3f318ba15757a6f34ff to your computer and use it in GitHub Desktop.
Save aik0aaac/550fdd9391c8b3f318ba15757a6f34ff to your computer and use it in GitHub Desktop.
Youtube Analytics APIの`query`APIのResponse内容。(TypeScript-Interface)
/**
* Youtube Analytics API > `query`のレスポンス。
* 公式Docs: https://developers.google.com/youtube/analytics/reference/reports/query?hl=ja
*/
export interface IQueryResponse {
/**
* リソース種別。
* `query`のレスポンスなら`youtubeAnalytics#resultTable`の固定値が返却。
*/
kind: "youtubeAnalytics#resultTable";
/**
* カラムヘッダー群。
* ディメンションが先頭要素に配置され、メトリクスはその後の要素として配置される。
*/
columnHeaders: {
/**
* カラム名。ディメンションやメトリクスの値が入る。
* 例: `views`, `deviceType`
*/
name: string;
/**
* カラムがディメンションかメトリクスのどちらか。
*/
columnType: "DIMENSION" | "METRIC";
/**
* カラムのデータ型。
* ↓に示したパターン以外にもあるかも。
*/
dataType: `STRING` | `INTEGER` | `FLOAT`;
}[];
/**
* カラム群。(データ)
* ディメンションとメトリクスのパターンによって、構造がかなり異なるのでany型で定義。
* `query`の該当結果がない場合、空配列ではなくプロパティごとなくなる。
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
rows?: any[];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment