Starting September 8, 2025, every new line item will need to declare whether or not they will serve Eurpoean Union (EU) political ads. Display & Video 360 API and SDF uploads that don't provide declarations will fail. See our deprecations page for more details on how to update your integration to make this declaration.
Stay organized with collections
Save and categorize content based on your preferences.
After Structured Data Files finish generating successfully, download the
resulting ZIP file from the provided resource location using
media.download.
Here's how to retrieve the file location and download the ZIP file:
# Import the object used for media download.fromgoogleapiclientimporthttpasgoogleHttp# Provide the name of the successfully completed sdfdownloadtask operation.operation_name=operation-name# Provide the path for the output file.output_path=output-path# Retrieve the completed operation.operation=service.sdfdownloadtasks().operations().get(operation_name).execute()# Retrieve the file location from the operation.file_location=operation["response"]["resourceName"]# Configure the media.download request.download_request=service.media().download_media(resourceName=file_location)# Create output stream for downloaded file.out_stream=io.FileIO(output_path,mode='wb')# Build downloader object.downloader=googleHttp.MediaIoBaseDownload(out_stream,download_request)# Download file in chunks until finished.download_finished=Falsewhiledownload_finishedisFalse:_,download_finished=downloader.next_chunk()print(f'File downloaded at {output_path}.')
Extract files
Decompress the downloaded ZIP file to extract the generated Structured Data
Files. They have generic names identifying their file type, such as
SDF-LineItems.csv.
If data for a requested resource couldn't be included in the generated
Structured Data file, the ZIP file will also include a "Skipped" file for that
resource, such as SDF-LineItems-Skipped.csv. "Skipped" files have a two column
structure. The first column identifies the skipped resource and the second
column contains the error message explaining their exclusion.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-04-15 UTC."],[],[],null,["# Download file\n\nAfter Structured Data Files finish generating successfully, download the\nresulting `ZIP` file from the provided resource location using\n[`media.download`](/display-video/api/sdf-upload/rest/v4/media/download).\n| **Note:** Specify the data format for your download response as `media` using the `alt` parameter, appending `?alt=media` to your download URL. Client libraries take care of this for you.\n\nHere's how to retrieve the file location and download the `ZIP` file: \n\n```python\n# Import the object used for media download.\nfrom googleapiclient import http as googleHttp\n\n# Provide the name of the successfully completed sdfdownloadtask operation.\noperation_name = operation-name\n\n# Provide the path for the output file.\noutput_path = output-path\n\n# Retrieve the completed operation.\noperation = service.sdfdownloadtasks().operations().get(operation_name\n ).execute()\n\n# Retrieve the file location from the operation.\nfile_location = operation[\"response\"][\"resourceName\"]\n\n# Configure the media.download request.\ndownload_request = service.media().download_media(resourceName=file_location)\n\n# Create output stream for downloaded file.\nout_stream = io.FileIO(output_path, mode='wb')\n\n# Build downloader object.\ndownloader = googleHttp.MediaIoBaseDownload(out_stream, download_request)\n\n# Download file in chunks until finished.\ndownload_finished = False\nwhile download_finished is False:\n _, download_finished = downloader.next_chunk()\n\nprint(f'File downloaded at {output_path}.')\n```\n\nExtract files\n-------------\n\nDecompress the downloaded `ZIP` file to extract the generated Structured Data\nFiles. They have generic names identifying their file type, such as\n`SDF-LineItems.csv`.\n\nIf data for a requested resource couldn't be included in the generated\nStructured Data file, the `ZIP` file will also include a \"Skipped\" file for that\nresource, such as `SDF-LineItems-Skipped.csv`. \"Skipped\" files have a two column\nstructure. The first column identifies the skipped resource and the second\ncolumn contains the error message explaining their exclusion."]]