您可以使用以下方法查看您的买家账号或其某个客户账号订阅的现有竞价包。您无法在 Marketplace API 中添加或更改竞价包。
获取单个竞价包
您可以使用 buyers.auctionPackages.get 方法检索您或您的至少一位客户订阅的特定 AuctionPackage。
如果您尝试查看买家账号未订阅的 AuctionPackage,则会收到错误消息。
以下示例演示了如何使用 get 方法检索单个 AuctionPackage。
REST
请求
GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/auctionPackages/558444393847004125?alt=json Authorization: Bearer ACCESS_TOKEN Content-Type: application/json
响应
{
"name":"buyers/12345678/auctionPackages/558444393847004125",
"creator":"buyers/240142376",
"displayName":"Luxury travel",
"description":"Web, display. Verticals include: travel & transportation, hotels & accommodation, ecotourism. Ads.txt targeting: direct & reseller. Minimum predicted viewability: 75%",
"createTime":"2038-06-28T19:12:38.823Z",
"updateTime":"2042-01-11T18:45:14.106Z",
"subscribedClients":[
"buyers/12345678/clients/873721984",
"buyers/12345678/clients/136428959"
]
}Java
/* * Copyright 2022 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 * * https://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.authorizedbuyers.marketplace.v1.buyers.auctionPackages; import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace; import com.google.api.services.authorizedbuyersmarketplace.v1.model.AuctionPackage; import com.google.api.services.samples.authorizedbuyers.marketplace.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; /** * This sample illustrates how to get an auction package for the given buyer and auction package ID. */ public class GetAuctionPackages { public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) { Long accountId = parsedArgs.getLong("account_id"); Long auctionPackageId = parsedArgs.getLong("auction_package_id"); String name = String.format("buyers/%s/auctionPackages/%d", accountId, auctionPackageId); AuctionPackage auctionPackage = null; try { auctionPackage = marketplaceClient.buyers().auctionPackages().get(name).execute(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response:%n%s", ex); System.exit(1); } System.out.printf( "Found auction package with ID \"%s\" for buyer account ID '%d':%n", auctionPackageId, accountId); Utils.printAuctionPackage(auctionPackage); } public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("GetAuctionPackages") .build() .defaultHelp(true) .description(("Get an auction package for the given buyer and auction package ID.")); parser .addArgument("-a", "--account_id") .help( "The resource ID of the buyers resource under which the auction package is being " + " retrieved. This will be used to construct the name used as a path parameter for" + " the auctionPackages.get request.") .required(true) .type(Long.class); parser .addArgument("--auction_package_id") .help( "The resource ID of the buyers.auctionPackages resource that is being retrieved. " + "This will be used to construct the name used as a path parameter for the " + "auctionPackages.get request.") .required(true) .type(Long.class); Namespace parsedArgs = null; try { parsedArgs = parser.parseArgs(args); } catch (ArgumentParserException ex) { parser.handleError(ex); System.exit(1); } AuthorizedBuyersMarketplace client = null; try { client = Utils.getMarketplaceClient(); } catch (IOException ex) { System.out.printf("Unable to create Marketplace 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); } execute(client, parsedArgs); } }
列出多个竞价包(买方级)
您可以使用 buyers.auctionPackages.list 方法来分页显示买方及其客户订阅的所有竞价包。
以下示例演示了如何使用 list 方法列出竞价包。
REST
请求
GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/auctionPackages?pageSize=3&alt=json Authorization: Bearer ACCESS_TOKEN Content-Type: application/json
响应
{
"auctionPackages": [
{
"name": "buyers/12345678/auctionPackages/558444393847004125",
"creator": "buyers/240142376",
"displayName": "Luxury travel",
"description": "Web, display. Verticals include: travel & transportation, hotels & accommodation, ecotourism. Ads.txt targeting: direct & reseller. Minimum predicted viewability: 75%",
"createTime": "2038-06-28T19:12:38.823Z",
"updateTime": "2042-01-11T18:45:14.106Z",
"subscribedClients": [
"buyers/12345678/clients/873721984",
"buyers/12345678/clients/136428959"
]
},
{
"name": "buyers/12345678/auctionPackages/558444393847627347",
"creator": "buyers/143579823",
"displayName": "Mars Top 25 Video",
"description": "Top 25 Sites in Mars Video",
"createTime": "2040-11-16T16:45:46.185Z",
"updateTime": "2041-05-03T13:53:17.151Z",
"subscribedClients": [
"buyers/12345678/clients/142940840"
]
},
{
"name": "buyers/12345678/auctionPackages/558444393848195715",
"creator": "buyers/12345678",
"displayName": "Mars Top 100 Sports",
"createTime": "2041-11-29T16:07:43.631Z",
"updateTime": "2041-11-29T16:07:43.631Z"
}
],
"nextPageToken": "CAMQ5Ja-7a7g9gIY5Ja-7a7g9gI="
}Java
/* * Copyright 2022 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 * * https://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.authorizedbuyers.marketplace.v1.buyers.auctionPackages; import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace; import com.google.api.services.authorizedbuyersmarketplace.v1.model.AuctionPackage; import com.google.api.services.authorizedbuyersmarketplace.v1.model.ListAuctionPackagesResponse; import com.google.api.services.samples.authorizedbuyers.marketplace.v1.Utils; import java.io.IOException; import java.security.GeneralSecurityException; import java.util.List; import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; /** This sample illustrates how to list auction packages for a given buyer account ID. */ public class ListAuctionPackages { public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) { Long accountId = parsedArgs.getLong("account_id"); Integer pageSize = parsedArgs.getInt("page_size"); String parentBuyerName = String.format("buyers/%s", accountId); String pageToken = null; System.out.printf("Found auction packages for buyer Account ID '%d':%n", accountId); do { List<AuctionPackage> auctionPackages = null; try { ListAuctionPackagesResponse response = marketplaceClient .buyers() .auctionPackages() .list(parentBuyerName) .setPageSize(pageSize) .setPageToken(pageToken) .execute(); auctionPackages = response.getAuctionPackages(); pageToken = response.getNextPageToken(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response:%n%s", ex); System.exit(1); } if (auctionPackages == null) { System.out.println("No auction packages found."); } else { for (AuctionPackage auctionPackage : auctionPackages) { Utils.printAuctionPackage(auctionPackage); } } } while (pageToken != null); } public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("ListAuctionPackages") .build() .defaultHelp(true) .description(("Lists publisher profiles associated with the given buyer account.")); parser .addArgument("-a", "--account_id") .help( "The resource ID of the buyers resource under which the auction packages resource " + "is being accessed. This will be used to construct the parent used as a path " + "parameter for the auctionPackages.list request.") .required(true) .type(Long.class); parser .addArgument("-p", "--page_size") .help( "The number of rows to return per page. The server may return fewer rows than " + "specified.") .setDefault(Utils.getMaximumPageSize()) .type(Integer.class); Namespace parsedArgs = null; try { parsedArgs = parser.parseArgs(args); } catch (ArgumentParserException ex) { parser.handleError(ex); System.exit(1); } AuthorizedBuyersMarketplace client = null; try { client = Utils.getMarketplaceClient(); } catch (IOException ex) { System.out.printf("Unable to create Marketplace 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); } execute(client, parsedArgs); } }
列出多个竞价包(出价方级)
您可以使用 bidders.auctionPackages.list 方法分页浏览出价方及其买家、客户和媒体策划人员订阅的所有竞价包。
以下示例演示了如何使用 list 方法列出竞价包。
REST
请求
GET https://authorizedbuyersmarketplace.googleapis.com/v1/bidders/12345678/auctionPackages?pageSize=3&alt=json Authorization: Bearer ACCESS_TOKEN Content-Type: application/json
响应
{
"auctionPackages": [
{
"name": "buyers/12345678/auctionPackages/558444393847004125",
"creator": "buyers/240142376",
"displayName": "Luxury travel",
"description": "Web, display. Verticals include: travel & transportation, hotels & accommodation, ecotourism. Ads.txt targeting: direct & reseller. Minimum predicted viewability: 75%",
"createTime": "2038-06-28T19:12:38.823Z",
"updateTime": "2042-01-11T18:45:14.106Z",
"subscribedClients": [
"buyers/12345678/clients/873721984",
"buyers/12345678/clients/136428959"
],
"subscribedMediaPlanners": [
{
"accountId": "11111111"
}
],
"eligibleSeatIds": [
"test_seat1",
"test_seat2",
"test_seat3"
]
},
{
"name": "buyers/12345678/auctionPackages/558444393847627347",
"creator": "buyers/143579823",
"displayName": "Mars Top 25 Video",
"description": "Top 25 Sites in Mars Video",
"createTime": "2040-11-16T16:45:46.185Z",
"updateTime": "2041-05-03T13:53:17.151Z",
"subscribedClients": [
"buyers/12345678/clients/142940840"
]
},
{
"name": "buyers/12345678/auctionPackages/558444393848195715",
"creator": "buyers/12345678",
"displayName": "Mars Top 100 Sports",
"createTime": "2041-11-29T16:07:43.631Z",
"updateTime": "2041-11-29T16:07:43.631Z"
}
],
"nextPageToken": "CAMQ5Ja-7a7g9gIY5Ja-7a7g9gI="
}