Amazon DSP Export Guide — Python Script

GMSF v1.2 Amazon DSP 15 min install
🎯
Objective
This Python script automatically exports your Amazon DSP campaign data with the granularity needed for GMSF v1.2 carbon analysis in Carbon Intelligence. Amazon DSP offers unique data on Amazon inventory sources (IMDb TV, Twitch, Fire TV, etc.).
⚙️
Installation
3 steps · 15 minutes
Prerequisites
  1. Python 3.8+ installed on your machine
  2. Install dependencies: pip install requests pandas
  3. Create an application in the Amazon Ads Developer Console
  4. Obtain your credentials: Client ID, Client Secret, Refresh Token
  5. Identify your DSP Profile ID in the Amazon Ads console
Configure
  1. Open the file carbon-intelligence-amazon-dsp-export.py
  2. Fill in the configuration variables at the beginning of the script:
    • CLIENT_ID = your Client ID
    • CLIENT_SECRET = your Client Secret
    • REFRESH_TOKEN = your Refresh Token
    • PROFILE_ID = your DSP Profile ID
  3. Set the output directory in OUTPUT_DIR
Run
  1. Run the script: python carbon-intelligence-amazon-dsp-export.py
  2. Exported data appears in OUTPUT_DIR
  3. Schedule regular execution via cron (Linux/macOS) or Task Scheduler (Windows)
📊
What is exported
11 tabs created automatically
TabContentUsage Carbon Intelligence
CI_CampaignsBy order/line item + weekEmissions overview
CI_DeviceDesktop, mobile, tablet, CTV, Fire TabletEnergy factor per device
CI_GeoBy country and regionGMSF v1.2 country energy mix
CI_PlacementsBy inventory sourceEnergy-intensive placements
CI_CreativeSizeBy creative sizeData transfer weight
CI_AdFormatDisplay, Video, OLV, STV, Audio (Amazon formats)Ad format factor
CI_VideoDetailed video data (duration, quartiles)Video carbon calculation
CI_SupplySourceAmazon inventory vs 3rd party🎯 Amazon DSP Specific
CI_EnvironmentDelivery contextDelivery parameters
CI_MetadataAccount and export informationTraceability and audit
CI_Export_CSVAll dimensions consolidatedDirect CI platform import
📁
Export CSV
Two options available
CSV files are automatically generated in the directory specified by OUTPUT_DIR after each script execution. You can import them directly into Carbon Intelligence or integrate them into your data pipeline.
🔗
Sharing with Carbon Intelligence
📨
Share the Google Sheet with: support@carbonintelligence.green (accès lecteur)
Or send the exported CSV by email to the same address.
🔧
Advanced Configuration
Script CONFIG section
# Advanced configuration variables:

LOOKBACK_DAYS: 90,                                      # Days of history to export
MIN_IMPRESSIONS: 1,                                     # Minimum impression threshold per row
REPORT_WAIT_SECONDS: 60,                                # Wait before fetching report
TOKEN_REFRESH_URL: 'https://api.amazon.com/auth/o2/token'
🛠️
Troubleshooting
"401 Unauthorized"
Your Refresh Token has expired or is invalid. Generate a new token from the Amazon Ads Developer Console and update REFRESH_TOKEN in the script.
"Profile not found"
Check that your PROFILE_ID is correct in the Amazon Ads console and matches your DSP profile.
"Report failed"
The report could not be generated. Check the date range and reduce LOOKBACK_DAYS if the range is too large.
"No access"
Check that your application permissions and DSP profile allow access to reports. Contact your Amazon Ads account manager if needed.
"Rate limit"
The Amazon Ads API limits requests. Wait at least 60 seconds between script executions, or increase REPORT_WAIT_SECONDS.
💬
Support
Email support@carbonintelligence.green
Script version 1.0.0
Methodology GMSF v1.2 (Ad Net Zero)