À partir du
8 septembre 2025, chaque nouvelle ligne devra indiquer si elle diffusera ou non des annonces à caractère politique dans l'Union européenne (UE). Les importations de fichiers SDF et les appels à l'API Display & Video 360 qui ne fournissent pas de déclarations échoueront. Pour savoir comment mettre à jour votre intégration afin d'effectuer cette déclaration, consultez notre
page sur les abandons de compatibilité.
Envoyer des requêtes
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Une fois la configuration terminée, vous pouvez envoyer des requêtes à l'API Display & Video 360.
Les exemples de code ci-dessous vous indiquent comment envoyer quelques requêtes simples:
- Créez un élément de campagne.
- Récupérer un élément de campagne spécifique
Pour obtenir la liste complète des méthodes, consultez la documentation de référence.
Créer une ressource
Voici un exemple de création d'un élément de campagne:
Java
// Create a line item object.
LineItem lineItem = new LineItem();
lineItem.setInsertionOrderId(insertion-order-id);
lineItem.setDisplayName(display-name);
lineItem.setLineItemType("LINE_ITEM_TYPE_DISPLAY_DEFAULT");
lineItem.setEntityStatus("ENTITY_STATUS_DRAFT");
// Create and set the line item flight.
LineItemFlight lineItemFlight = new LineItemFlight();
lineItemFlight
.setFlightDateType("LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED");
lineItem.setFlight(lineItemFlight);
// Create and set the line item budget.
LineItemBudget lineItemBudget = new LineItemBudget();
lineItemBudget
.setBudgetAllocationType("LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED");
lineItem.setBudget(lineItemBudget);
// Create and set the pacing setting.
Pacing pacing = new Pacing();
pacing.setPacingPeriod("PACING_PERIOD_DAILY");
pacing.setPacingType("PACING_TYPE_EVEN");
pacing.setDailyMaxMicros(10000L);
lineItem.setPacing(pacing);
// Create and set the frequency cap.
FrequencyCap frequencyCap = new FrequencyCap();
frequencyCap.setTimeUnit("TIME_UNIT_DAYS");
frequencyCap.setTimeUnitCount(1);
frequencyCap.setMaxImpressions(10);
lineItem.setFrequencyCap(frequencyCap);
// Create and set the partner revenue model.
PartnerRevenueModel partnerRevenueModel = new PartnerRevenueModel();
partnerRevenueModel
.setMarkupType("PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM");
partnerRevenueModel.setMarkupAmount(10000L);
lineItem.setPartnerRevenueModel(partnerRevenueModel);
// Set the list of IDs of the creatives associated with the line item.
lineItem.setCreativeIds(creative-ids);
// Create and set the bidding strategy.
BiddingStrategy biddingStrategy = new BiddingStrategy();
biddingStrategy
.setFixedBid(new FixedBidStrategy().setBidAmountMicros(100000L));
lineItem.setBidStrategy(biddingStrategy);
// Declare whether or not the line item will serve EU political ads.
lineItem.setContainsEuPoliticalAds(eu-political-advertising-status);
// Create the line item.
LineItem response =
service.advertisers().lineItems().create(advertiser-id, lineItem).execute();
Python
# Create a line item object.
line_item_obj = {
'insertionOrderId' : insertion-order-id,
'displayName': display-name,
'lineItemType': 'LINE_ITEM_TYPE_DISPLAY_DEFAULT',
'entityStatus': 'ENTITY_STATUS_DRAFT',
'flight': {
'flightDateType': 'LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED'
},
'budget': {
'budgetAllocationType': 'LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED'
},
'pacing': {
'pacingPeriod': 'PACING_PERIOD_DAILY',
'pacingType': 'PACING_TYPE_EVEN',
'dailyMaxMicros': 10000
},
'frequencyCap': {
'timeUnit': 'TIME_UNIT_DAYS',
'timeUnitCount': 1,
'maxImpressions': 10
},
'partnerRevenueModel': {
'markupType': 'PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM',
'markupAmount': 10000
},
'creativeIds': creative-ids,
'bidStrategy': {
'fixedBid': {
'bidAmountMicros': 100000
}
},
'containsEuPoliticalAds': eu-political-advertising-status
}
# Create the line item.
lineItem = service.advertisers().lineItems().create(
advertiserId=advertiser-id,
body=line_item_obj
).execute()
PHP
// Create a line item object.
$lineItem = new Google_Service_DisplayVideo_LineItem();
$lineItem->setInsertionOrderId(insertion-order-id);
$lineItem->setDisplayName(display-name);
$lineItem->setLineItemType('LINE_ITEM_TYPE_DISPLAY_DEFAULT');
$lineItem->setEntityStatus('ENTITY_STATUS_DRAFT');
// Create and set the line item flight.
$flight = new Google_Service_DisplayVideo_LineItemFlight();
$flight->setFlightDateType('LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED');
$lineItem->setFlight($flight);
// Create and set the line item budget.
$budget = new Google_Service_DisplayVideo_LineItemBudget();
$budget->setBudgetAllocationType(
'LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED'
);
$lineItem->setBudget($budget);
// Create and set the pacing setting.
$pacing = new Google_Service_DisplayVideo_Pacing();
$pacing->setPacingPeriod('PACING_PERIOD_DAILY');
$pacing->setPacingType('PACING_TYPE_EVEN');
$pacing->setDailyMaxMicros(10000);
$lineItem->setPacing($pacing);
// Create and set the frequency cap.
$frequencyCap = new Google_Service_DisplayVideo_FrequencyCap();
$frequencyCap->setMaxImpressions(10);
$frequencyCap->setTimeUnit('TIME_UNIT_DAYS');
$frequencyCap->setTimeUnitCount(1);
$lineItem->setFrequencyCap($frequencyCap);
// Create and set the partner revenue model.
$partnerRevenueModel =
new Google_Service_DisplayVideo_PartnerRevenueModel();
$partnerRevenueModel->setMarkupType(
'PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM'
);
$partnerRevenueModel->setMarkupAmount(10000);
$lineItem->setPartnerRevenueModel($partnerRevenueModel);
// Set the list of IDs of the creatives associated with the line item.
lineItem >setCreativeIds(creative-ids);
// Create and set the bidding strategy.
$biddingStrategy = new Google_Service_DisplayVideo_BiddingStrategy();
$fixedBidStrategy = new Google_Service_DisplayVideo_FixedBidStrategy();
$fixedBidStrategy->setBidAmountMicros(100000);
$biddingStrategy->setFixedBid($fixedBidStrategy);
$lineItem->setBidStrategy($biddingStrategy);
// Declare whether or not the line item will serve EU political ads.
$lineItem->setContainsEuPoliticalAds(eu-political-advertising-status);
// Create the line item.
$result = $this->service->advertisers_lineItems->create(
advertiser-id,
$lineItem
);
Récupérer une ressource spécifique
Voici un exemple de récupération d'un élément de campagne spécifique:
Java
// Get the line item.
LineItem lineItem =
service
.advertisers()
.lineItems()
.get(advertiser-id, line-item-id)
.execute();
Python
# Get the line item.
lineItem = service.advertisers().lineItems.get(
advertiserId=advertiser-id,
lineItemId=line-item-id
).execute()
PHP
// Get the line item.
$lineItem = $this->service->advertisers_lineItems->get(
advertiser-id,
line-item-id
);
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/26 (UTC).
[null,null,["Dernière mise à jour le 2025/08/26 (UTC)."],[[["\u003cp\u003eAfter setup, send requests to the Display & Video 360 API to manage line items and other resources.\u003c/p\u003e\n"],["\u003cp\u003eCode samples demonstrate how to create and retrieve line items using the API in Java, Python, and PHP.\u003c/p\u003e\n"],["\u003cp\u003eThe reference documentation provides a comprehensive list of available API methods for interacting with Display & Video 360.\u003c/p\u003e\n"]]],["The content details sending requests to the Display & Video 360 API, specifically demonstrating how to create and retrieve a line item. Creating a line item involves defining properties like `insertionOrderId`, `displayName`, `lineItemType`, status, flight details, budget, pacing, frequency cap, partner revenue model, creative IDs, and bidding strategy, then using the create method. Retrieving an item uses the `get` method. Code examples are provided in Java, Python, and PHP.\n"],null,["After you've set everything up, you can send requests to the Display \\& Video 360 API.\n\nThe following code samples demonstrate how to send a few simple requests:\n\n- Create a line item.\n- Retrieve a specific line item.\n\nFor a full list of methods, see the [reference documentation](/display-video/api/reference/rest).\n\nCreate a resource\n\nHere's an example of [create a line item](/display-video/api/reference/rest/current/advertisers.lineItems/create): \n\nJava \n\n```java\n// Create a line item object.\nLineItem lineItem = new LineItem();\nlineItem.setInsertionOrderId(insertion-order-id);\nlineItem.setDisplayName(display-name);\nlineItem.setLineItemType(\"LINE_ITEM_TYPE_DISPLAY_DEFAULT\");\nlineItem.setEntityStatus(\"ENTITY_STATUS_DRAFT\");\n\n// Create and set the line item flight.\nLineItemFlight lineItemFlight = new LineItemFlight();\nlineItemFlight\n .setFlightDateType(\"LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED\");\nlineItem.setFlight(lineItemFlight);\n\n// Create and set the line item budget.\nLineItemBudget lineItemBudget = new LineItemBudget();\nlineItemBudget\n .setBudgetAllocationType(\"LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED\");\nlineItem.setBudget(lineItemBudget);\n\n// Create and set the pacing setting.\nPacing pacing = new Pacing();\npacing.setPacingPeriod(\"PACING_PERIOD_DAILY\");\npacing.setPacingType(\"PACING_TYPE_EVEN\");\npacing.setDailyMaxMicros(10000L);\nlineItem.setPacing(pacing);\n\n// Create and set the frequency cap.\nFrequencyCap frequencyCap = new FrequencyCap();\nfrequencyCap.setTimeUnit(\"TIME_UNIT_DAYS\");\nfrequencyCap.setTimeUnitCount(1);\nfrequencyCap.setMaxImpressions(10);\nlineItem.setFrequencyCap(frequencyCap);\n\n// Create and set the partner revenue model.\nPartnerRevenueModel partnerRevenueModel = new PartnerRevenueModel();\npartnerRevenueModel\n .setMarkupType(\"PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM\");\npartnerRevenueModel.setMarkupAmount(10000L);\nlineItem.setPartnerRevenueModel(partnerRevenueModel);\n\n// Set the list of IDs of the creatives associated with the line item.\nlineItem.setCreativeIds(creative-ids);\n\n// Create and set the bidding strategy.\nBiddingStrategy biddingStrategy = new BiddingStrategy();\nbiddingStrategy\n .setFixedBid(new FixedBidStrategy().setBidAmountMicros(100000L));\nlineItem.setBidStrategy(biddingStrategy);\n\n// Declare whether or not the line item will serve EU political ads.\nlineItem.setContainsEuPoliticalAds(eu-political-advertising-status);\n\n// Create the line item.\nLineItem response =\n service.advertisers().lineItems().create(advertiser-id, lineItem).execute();\n```\n\nPython \n\n```python\n# Create a line item object.\nline_item_obj = {\n 'insertionOrderId' : insertion-order-id,\n 'displayName': display-name,\n 'lineItemType': 'LINE_ITEM_TYPE_DISPLAY_DEFAULT',\n 'entityStatus': 'ENTITY_STATUS_DRAFT',\n 'flight': {\n 'flightDateType': 'LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED'\n },\n 'budget': {\n 'budgetAllocationType': 'LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED'\n },\n 'pacing': {\n 'pacingPeriod': 'PACING_PERIOD_DAILY',\n 'pacingType': 'PACING_TYPE_EVEN',\n 'dailyMaxMicros': 10000\n },\n 'frequencyCap': {\n 'timeUnit': 'TIME_UNIT_DAYS',\n 'timeUnitCount': 1,\n 'maxImpressions': 10\n },\n 'partnerRevenueModel': {\n 'markupType': 'PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM',\n 'markupAmount': 10000\n },\n 'creativeIds': creative-ids,\n 'bidStrategy': {\n 'fixedBid': {\n 'bidAmountMicros': 100000\n }\n },\n 'containsEuPoliticalAds': eu-political-advertising-status\n}\n\n# Create the line item.\nlineItem = service.advertisers().lineItems().create(\n advertiserId=advertiser-id,\n body=line_item_obj\n).execute()\n```\n\nPHP \n\n```php\n// Create a line item object.\n$lineItem = new Google_Service_DisplayVideo_LineItem();\n$lineItem-\u003esetInsertionOrderId(\u003cvar translate=\"no\"\u003einsertion-order-id\u003c/var\u003e);\n$lineItem-\u003esetDisplayName(\u003cvar translate=\"no\"\u003edisplay-name\u003c/var\u003e);\n$lineItem-\u003esetLineItemType('LINE_ITEM_TYPE_DISPLAY_DEFAULT');\n$lineItem-\u003esetEntityStatus('ENTITY_STATUS_DRAFT');\n\n// Create and set the line item flight.\n$flight = new Google_Service_DisplayVideo_LineItemFlight();\n$flight-\u003esetFlightDateType('LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED');\n$lineItem-\u003esetFlight($flight);\n\n// Create and set the line item budget.\n$budget = new Google_Service_DisplayVideo_LineItemBudget();\n$budget-\u003esetBudgetAllocationType(\n 'LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED'\n);\n$lineItem-\u003esetBudget($budget);\n\n// Create and set the pacing setting.\n$pacing = new Google_Service_DisplayVideo_Pacing();\n$pacing-\u003esetPacingPeriod('PACING_PERIOD_DAILY');\n$pacing-\u003esetPacingType('PACING_TYPE_EVEN');\n$pacing-\u003esetDailyMaxMicros(10000);\n$lineItem-\u003esetPacing($pacing);\n\n// Create and set the frequency cap.\n$frequencyCap = new Google_Service_DisplayVideo_FrequencyCap();\n$frequencyCap-\u003esetMaxImpressions(10);\n$frequencyCap-\u003esetTimeUnit('TIME_UNIT_DAYS');\n$frequencyCap-\u003esetTimeUnitCount(1);\n$lineItem-\u003esetFrequencyCap($frequencyCap);\n\n// Create and set the partner revenue model.\n$partnerRevenueModel =\n new Google_Service_DisplayVideo_PartnerRevenueModel();\n$partnerRevenueModel-\u003esetMarkupType(\n 'PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM'\n);\n$partnerRevenueModel-\u003esetMarkupAmount(10000);\n$lineItem-\u003esetPartnerRevenueModel($partnerRevenueModel);\n\n// Set the list of IDs of the creatives associated with the line item.\nlineItem \u003esetCreativeIds(\u003cvar translate=\"no\"\u003ecreative-ids\u003c/var\u003e);\n\n// Create and set the bidding strategy.\n$biddingStrategy = new Google_Service_DisplayVideo_BiddingStrategy();\n$fixedBidStrategy = new Google_Service_DisplayVideo_FixedBidStrategy();\n$fixedBidStrategy-\u003esetBidAmountMicros(100000);\n$biddingStrategy-\u003esetFixedBid($fixedBidStrategy);\n$lineItem-\u003esetBidStrategy($biddingStrategy);\n\n// Declare whether or not the line item will serve EU political ads.\n$lineItem-\u003esetContainsEuPoliticalAds(\u003cvar translate=\"no\"\u003eeu-political-advertising-status\u003c/var\u003e);\n\n// Create the line item.\n$result = $this-\u003eservice-\u003eadvertisers_lineItems-\u003ecreate(\n \u003cvar translate=\"no\"\u003eadvertiser-id\u003c/var\u003e,\n $lineItem\n);\n```\n\nRetrieve a specific resource\n\nHere's an example of [retrieve a specific line item](/display-video/api/reference/rest/current/advertisers.lineItems/get): \n\nJava \n\n```java\n// Get the line item.\nLineItem lineItem =\n service\n .advertisers()\n .lineItems()\n .get(advertiser-id, line-item-id)\n .execute();\n```\n\nPython \n\n```python\n# Get the line item.\nlineItem = service.advertisers().lineItems.get(\n advertiserId=advertiser-id,\n lineItemId=line-item-id\n).execute()\n```\n\nPHP \n\n```php\n// Get the line item.\n$lineItem = $this-\u003eservice-\u003eadvertisers_lineItems-\u003eget(\n \u003cvar translate=\"no\"\u003eadvertiser-id\u003c/var\u003e,\n \u003cvar translate=\"no\"\u003eline-item-id\u003c/var\u003e\n);\n```"]]