レポート実行オペレーションは、Operation オブジェクトで表される長時間実行オペレーションとして非同期で実行されます。レポート実行オペレーションの出力は、Report オブジェクトに基づくレポート結果です。
このガイドでは、Curation Partners API を使用してレポート実行オペレーションを取得し、オペレーションのステータスをポーリングする方法と、完了したレポート実行オペレーションのレポート結果を取得する方法について説明します。
始める前に
続行する前に、次のことを行う必要があります。
- 認証を設定します。
- レポートの実行を開始して、長時間実行オペレーションのリソース名を取得します。
レポート実行のステータスをポーリングする
レポート実行オペレーションの実行ステータスを確認するには、curators.reports.operations.get メソッドを使用します。
次の例では、GET リクエストを行ってオペレーションをポーリングします。
REST
リクエスト
curl \
'https://curationpartners.googleapis.com/v1/curators/ACCOUNT_ID/reports/123456789/operations/10486370264' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Accept: application/json' \
--compressed
次のように置き換えます。
ACCOUNT_ID: アカウント ID。ACCESS_TOKEN: 自分のアクセス トークン。
レスポンス
正常に完了すると、レスポンスは Operation になり、done フィールドが true に設定され、response ペイロードに reportResult リソース名が入力されます。
{
"name": "curators/ACCOUNT_ID/reports/123456789/operations/10486370264",
"done": true,
"metadata": {
"@type": "type.googleapis.com/google.ads.curationpartners.v1.RunReportMetadata",
"percentComplete": 100
},
"response": {
"@type": "type.googleapis.com/google.ads.curationpartners.v1.RunReportResponse",
"reportResult": "curators/ACCOUNT_ID/reports/123456789/results/10486370264"
}
}
Java
/* * Copyright (c) 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package com.google.api.services.samples.curationpartners.v1.curators.reports.operations; import com.google.api.services.curationpartners.v1.CurationPartners; import com.google.api.services.curationpartners.v1.model.Operation; import com.google.api.services.samples.curationpartners.v1.Utils; import java.io.IOException; import java.security.GeneralSecurityException; import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; public class GetReportOperation { /** * Executes the get operation for a report operation. * * @param curationPartnersClient the initialized Curation Partners API client. * @param accountId the account ID of the curator. * @param reportId the resource ID of the report. * @param operationId the resource ID of the report operation. * @throws IOException if the API returns an error. */ public static void execute( CurationPartners curationPartnersClient, Long accountId, String reportId, String operationId) throws IOException { String name = String.format( "curators/%s/reports/%s/operations/%s", accountId, reportId, operationId); System.out.printf("Getting report operation with name \"%s\".%n", name); // Get the status of the report operation. Operation operation = curationPartnersClient .curators() .reports() .operations() .get(name) .execute(); System.out.println("Successfully retrieved report operation:"); Utils.jsonPrettyPrint(operation); } /** * Creates and configures the ArgumentParser for this sample. * * @return the configured ArgumentParser. */ private static ArgumentParser createArgumentParser() { ArgumentParser parser = ArgumentParsers.newFor("GetReportOperation") .build() .defaultHelp(true) .description("Gets the status of a long-running report operation. If the " + "operation is done, you can view the report contents with the " + "`curators.reports.results.fetchRows` method."); // Required arguments. parser .addArgument("-a", "--account_id") .help("The account ID of the curator.") .required(true) .type(Long.class); parser .addArgument("-r", "--report_id") .help("The resource ID of the report.") .required(true); parser .addArgument("-o", "--operation_id") .help("The resource ID of the report operation to retrieve.") .required(true); return parser; } public static void main(String[] args) { ArgumentParser parser = createArgumentParser(); Namespace parsedArgs = null; try { parsedArgs = parser.parseArgs(args); } catch (ArgumentParserException ex) { parser.handleError(ex); System.exit(1); } CurationPartners client = null; try { client = Utils.getCurationPartnersClient(); } catch (IOException ex) { System.out.printf("Unable to create Curation Partners API service:%n%s", ex); System.out.println("Did you specify a valid path to a service account key file?"); System.exit(1); } catch (GeneralSecurityException ex) { System.out.printf("Unable to establish secure HttpTransport:%n%s", ex); System.exit(1); } try { execute( client, parsedArgs.getLong("account_id"), parsedArgs.getString("report_id"), parsedArgs.getString("operation_id")); } catch (IOException ex) { System.out.printf("Curation Partners API returned error response:%n%s", ex); System.exit(1); } } }
done フィールドを使用してオペレーションのステータスをポーリングする方法は次のとおりです。
- レスポンスの
doneフィールドがfalse値の場合、レポート実行オペレーションはまだ処理中です。 - レスポンスの
doneフィールドがtrue値の場合、レポート実行オペレーションは完了しています。レスポンスの本文のOperationオブジェクトには、次のいずれかのフィールドも含まれます。response: レポート実行オペレーションが成功したことを示します。このフィールドは、type.googleapis.com/google.ads.curationpartners.v1.RunReportResponse型に設定された@typeフィールドが入力されたオブジェクトです。RunReportResponse型には、対応するレポートresultの名前を含むreportResultフィールドが入力されます。error: レポート実行オペレーションが成功しなかったことを示します。errorフィールドには、レポートの実行が失敗した理由を説明するStatusオブジェクトが入力されます。
完了したレポートから行を取得する
完了したレポート実行オペレーションの内容は、curators.reports.results.fetchRows メソッドで取得できます。レポート結果の name パスパラメータを入力する必要があります。これは、完全なレポート実行オペレーションの reportResult フィールドのリソース名です。
次の例では、結果行を取得する GET リクエストを作成します。
REST
リクエスト
curl \
'https://curationpartners.googleapis.com/v1/curators/ACCOUNT_ID/reports/123456789/results/10486370264:fetchRows?pageSize=1' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Accept: application/json' \
--compressed
レスポンス
{
"rows": [
{
"dimensionValues": [
{
"stringValue": "2026-08-01"
},
{
"stringValue": "segment-1001"
}
],
"metricValueGroups": [
{
"primaryValues": [
{
"intValue": "150000"
},
{
"intValue": "3200"
},
{
"doubleValue": 450.75
},
{
"doubleValue": 45.08
}
]
}
]
}
],
"runTime": "2026-08-05T12:00:00Z",
"dateRanges": [
{
"startDate": {
"year": 2026,
"month": 7,
"day": 6
},
"endDate": {
"year": 2026,
"month": 8,
"day": 4
}
}
],
"totalRowCount": 2,
"nextPageToken": "QC7nzW91c2VTcGFubmVyQ29udGlubWF0aW6uVG9wZY45NP=="
}
Java
/* * Copyright (c) 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package com.google.api.services.samples.curationpartners.v1.curators.reports.results; import com.google.api.services.curationpartners.v1.CurationPartners; import com.google.api.services.curationpartners.v1.model.FetchReportResultRowsResponse; import com.google.api.services.samples.curationpartners.v1.Utils; import java.io.IOException; import java.security.GeneralSecurityException; import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; public class FetchReportResultRows { /** * Executes the fetchRows operation for report result rows. * * @param curationPartnersClient the initialized Curation Partners API client. * @param accountId the account ID of the curator. * @param reportId the resource ID of the report. * @param resultId the resource ID of the report result. * @param pageSize the maximum number of rows to return per page. * @param pageToken the page token from a previous response, if any. * @throws IOException if the API returns an error. */ public static void execute( CurationPartners curationPartnersClient, Long accountId, String reportId, String resultId, Integer pageSize, String pageToken) throws IOException { String name = String.format("curators/%s/reports/%s/results/%s", accountId, reportId, resultId); System.out.printf("Fetching report result rows for \"%s\".%n", name); CurationPartners.Curators.Reports.Results.FetchRows request = curationPartnersClient.curators().reports().results().fetchRows(name); if (pageSize != null) { request.setPageSize(pageSize); } if (pageToken != null) { request.setPageToken(pageToken); } FetchReportResultRowsResponse response = request.execute(); System.out.println("Successfully fetched report result rows:"); Utils.jsonPrettyPrint(response); } /** * Creates and configures the ArgumentParser for this sample. * * @return the configured ArgumentParser. */ private static ArgumentParser createArgumentParser() { ArgumentParser parser = ArgumentParsers.newFor("FetchReportResultRows") .build() .defaultHelp(true) .description("Fetches rows for a completed report result."); // Required arguments. parser .addArgument("-a", "--account_id") .help("The account ID of the curator.") .required(true) .type(Long.class); parser .addArgument("-r", "--report_id") .help("The resource ID of the report.") .required(true); parser .addArgument("--result_id") .help("The resource ID of the report result. This is identical to the resource ID of " + "the corresponding report run operation.") .required(true); // Optional arguments. parser .addArgument("--page_size") .help("The maximum number of rows to return per page.") .type(Integer.class); parser .addArgument("--page_token") .help("A page token, received from a previous `FetchReportResultRows` call."); return parser; } public static void main(String[] args) { ArgumentParser parser = createArgumentParser(); Namespace parsedArgs = null; try { parsedArgs = parser.parseArgs(args); } catch (ArgumentParserException ex) { parser.handleError(ex); System.exit(1); } CurationPartners client = null; try { client = Utils.getCurationPartnersClient(); } catch (IOException ex) { System.out.printf("Unable to create Curation Partners API service:%n%s", ex); System.out.println("Did you specify a valid path to a service account key file?"); System.exit(1); } catch (GeneralSecurityException ex) { System.out.printf("Unable to establish secure HttpTransport:%n%s", ex); System.exit(1); } try { execute( client, parsedArgs.getLong("account_id"), parsedArgs.getString("report_id"), parsedArgs.getString("result_id"), parsedArgs.getInt("page_size"), parsedArgs.getString("page_token")); } catch (IOException ex) { System.out.printf("Curation Partners API returned error response:%n%s", ex); System.exit(1); } } }
次のクエリ パラメータを指定できます。
pageSize: 返される行の最大数。デフォルトは 1,000 行、最大値は 10,000 行です。pageToken: 前のfetchRowsレスポンスで返されたページトークン。次の行のバッチを取得します。
レスポンスには、次のフィールドが含まれます。
rows:Rowオブジェクトの配列。各行には次の情報が含まれます。dimensionValues: リクエストされた各ディメンションの値。レポート定義のディメンションと同じ順序で並べられます。metricValueGroups: 日付範囲に対応する指標値のグループ。各グループには、レポート定義の指標と同じ順序で並べられたprimaryValuesリストが含まれています。
dateRanges: レポートの計算された固定期間。dateRangesフィールドは、最初のページのレスポンス本文にのみ含まれます。totalRowCount: レポート結果の行の合計数。totalRowCountフィールドは、最初のページのレスポンス本文にのみ含まれます。nextPageToken: 後続のリクエストで渡して、次のページの行を取得するトークン。追加の行が存在しない場合、Curation Partners API はこのフィールドをレスポンスの本文から省略します。
curators.reports.results.fetchRows REST の例では、rows の各項目はレポートで構成された ReportDefinition に直接マッピングされます。
dimensionValues:reportDefinition.dimensionsフィールドの各ディメンションに対応する値が、指定した順序で格納されます。この例では、最初の値2026-08-01はDATEディメンションに対応し、2 番目の値segment-1001はCURATION_DATA_SEGMENT_IDディメンションに対応します。metricValueGroups: レポートの日付範囲でグループ化された指標値が含まれます。各グループのprimaryValuesフィールドには、reportDefinition.metricsフィールドの各指標に対応する値が、指定した順序で含まれています。この例では、4 つの値は次のMetric列挙型の値に対応しています。IMPRESSIONS:150000CLICKS:3200SPEND:450.75CURATION_PARTNER_FEE:45.08
dateRanges: レポート定義で構成された相対範囲THIS_MONTH_TO_DATEについて Google が算出した固定の日付範囲が含まれます。
次のステップ
- Curation Partners API を使用してレポートを作成、変更する方法について説明します。
- Curation Partners API を使用して既存のレポートを表示する方法を確認する。
- Curation Partners API を使用してレポートを実行する方法をご確認ください。