С 8 сентября 2025 года в каждой новой позиции необходимо будет указывать, будет ли она показывать политическую рекламу Европейского союза (ЕС). Загрузки через Display & Video 360 API и SDF без таких указаний будут отклонены. Подробнее о том, как обновить интеграцию и указать это указание, см. на странице «Устаревшие функции».
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
После успешного завершения операции и извлечения имени ресурса из ответа о завершенной операции вы готовы загрузить zip-файл, содержащий сгенерированные файлы SDF, с помощью метода media.download .
Вот пример использования клиентской библиотеки для загрузки полученного файла:
Ява
// Extract download file resource name to use in download requestStringdownloadResourceName=operationResponse.getResponse().get("resourceName").toString();// Configure the Media.download requestMedia.DownloaddownloadRequest=service.media().download(downloadResourceName);// Create output stream for downloaded fileFileOutputStreamoutStream=newFileOutputStream(output-file);// Download filedownloadRequest.executeMediaAndDownloadTo(outStream);System.out.printf("File downloaded to %s\n",outputFile);
Питон
# Extract download file resource name to use in download requestresourceName=operation["response"]["resourceName"]# Configure the Media.download requestdownloadRequest=service.media().download_media(resourceName=resourceName)# Create output stream for downloaded fileoutStream=io.FileIO(output-file,mode='wb')# Make downloader objectdownloader=googleHttp.MediaIoBaseDownload(outStream,downloadRequest)# Download media file in chunks until finisheddownload_finished=Falsewhiledownload_finishedisFalse:_,download_finished=downloader.next_chunk()print("File downloaded to %s"%output-file)
PHP
// Get client and set defer so it doesn't immediately return.$client = $this->service->getClient();$client->setDefer(true);// Build media download request.$request = $this->service->media->download( $operation->getResponse()['resourceName'], array('alt' => 'media'));// Call the API, getting the generated SDF.$response = $client->execute($request);$responseBody = $response->getBody();// Writes the downloaded file. If the file already exists, it is// overwritten.file_put_contents(output-file, $responseBody);$client->setDefer(false);printf('File saved to: %s\n', output-file);
Как только ваш файл будет загружен и распакован, вам станут доступны сгенерированные файлы структурированных данных. Сгенерированные файлы будут иметь общие имена, идентифицирующие тип файла SDF (пример: SDF-LineItems.csv ).
Пропущенные файлы
Если данные для запрошенного ресурса не могут быть включены в соответствующий файл структурированных данных, загруженный zip-файл может содержать «пропущенный» файл (пример: SDF-LineItems-Skipped.csv ). Этот файл будет иметь структуру из двух столбцов: первый будет содержать идентификаторы ресурсов, которые не удалось включить, а второй — причину их исключения.
Ресурсы могут быть пропущены по многим причинам, в том числе из-за того, что они находятся в неподдерживаемом состоянии или имеют неподдерживаемый тип. Избегайте пропуска ресурсов, используя самую последнюю версию SDF.
[null,null,["Последнее обновление: 2025-07-24 UTC."],[[["\u003cp\u003eAfter a successful operation, download the generated SDFs as a zip file using the \u003ccode\u003emedia.download\u003c/code\u003e method, ensuring the \u003ccode\u003ealt\u003c/code\u003e parameter is set to \u003ccode\u003emedia\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eClient libraries simplify the download process, but if using a direct download URL, append \u003ccode\u003e?alt=media\u003c/code\u003e to ensure proper data format.\u003c/p\u003e\n"],["\u003cp\u003eExtract the download file resource name from the operation response to initiate the download using your preferred client library (Java, Python, or PHP examples provided).\u003c/p\u003e\n"],["\u003cp\u003eDownloaded zip files contain generically named SDF files; a "Skipped" file might be included if certain resources could not be processed, detailing the reasons for exclusion.\u003c/p\u003e\n"],["\u003cp\u003eMinimize skipped resources by utilizing the latest SDF version to ensure compatibility and support for your resource types and states.\u003c/p\u003e\n"]]],["After a successful operation, extract the `resourceName` to download a zip file containing generated SDFs. Use the `media.download` method with `alt=media` to specify the data format. Client libraries automate this process. Download the file by configuring a `Media.Download` request, creating an output stream, and executing the request to download the file into the stream. The zip file contains structured data files like `SDF-LineItems.csv`. A `Skipped.csv` file might be included, listing resources not included and why.\n"],null,["# Download the SDF\n\nOnce your operation has finished successfully and you've extracted the resource\nname from the completed operation response, you are ready to download the zip\nfile containing your generated SDFs using the [`media.download`](/display-video/api/reference/rest/current/media/download)\nmethod.\n| **Note:** You must specify the data format for your download response as `media` through the `alt` parameter. This can be done by appending `?alt=media` to your download url. Client libraries take care of this for you.\n\nHere's an example of how to use a client library to download the resulting file: \n\n### Java\n\n```java\n// Extract download file resource name to use in download request\nString downloadResourceName = operationResponse.getResponse()\n .get(\"resourceName\").toString();\n\n// Configure the Media.download request\nMedia.Download downloadRequest =\n service\n .media()\n .download(downloadResourceName);\n\n// Create output stream for downloaded file\nFileOutputStream outStream =\n new FileOutputStream(output-file);\n\n// Download file\ndownloadRequest.executeMediaAndDownloadTo(outStream);\n\nSystem.out.printf(\"File downloaded to %s\\n\", outputFile);\n```\n\n### Python\n\n```python\n# Extract download file resource name to use in download request\nresourceName = operation[\"response\"][\"resourceName\"]\n\n# Configure the Media.download request\ndownloadRequest = service.media().download_media(resourceName=resourceName)\n\n# Create output stream for downloaded file\noutStream = io.FileIO(output-file, mode='wb')\n\n# Make downloader object\ndownloader = googleHttp.MediaIoBaseDownload(outStream, downloadRequest)\n\n# Download media file in chunks until finished\ndownload_finished = False\nwhile download_finished is False:\n _, download_finished = downloader.next_chunk()\n\nprint(\"File downloaded to %s\" % output-file)\n```\n\n### PHP\n\n```php\n// Get client and set defer so it doesn't immediately return.\n$client = $this-\u003eservice-\u003egetClient();\n$client-\u003esetDefer(true);\n\n// Build media download request.\n$request = $this-\u003eservice-\u003emedia-\u003edownload(\n $operation-\u003egetResponse()['resourceName'],\n array('alt' =\u003e 'media')\n);\n\n// Call the API, getting the generated SDF.\n$response = $client-\u003eexecute($request);\n$responseBody = $response-\u003egetBody();\n\n// Writes the downloaded file. If the file already exists, it is\n// overwritten.\nfile_put_contents(\u003cvar translate=\"no\"\u003eoutput-file\u003c/var\u003e, $responseBody);\n$client-\u003esetDefer(false);\n\nprintf('File saved to: %s\\n', \u003cvar translate=\"no\"\u003eoutput-file\u003c/var\u003e);\n```\n\nOnce your file is downloaded and unzipped, your generated structured data files\nwill be available to you. The generated files will have generic names\nidentifying the SDF file type (example: `SDF-LineItems.csv`).\n\nSkipped files\n-------------\n\nIf data for a requested resource cannot be included in the corresponding\nstructured data file, the zip file downloaded might include a \"Skipped\" file\n(example: `SDF-LineItems-Skipped.csv`). This file will have a two-column\nstructure, the first containing the IDs of the resources that couldn't be\nincluded and the second containing the reason for their exclusion.\n\nResources may be skipped for many reasons, including being in an unsupported\nstate or of an unsupported type. Avoid having resources skipped by using the\nmost recent version of SDF."]]