Carbon Intelligence™
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
- Python 3.8+ installed on your machine
- Install dependencies:
pip install requests pandas - Create an application in the Amazon Ads Developer Console
- Obtain your credentials: Client ID, Client Secret, Refresh Token
- Identify your DSP Profile ID in the Amazon Ads console
Configure
- Open the file
carbon-intelligence-amazon-dsp-export.py - 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
- •
- Set the output directory in
OUTPUT_DIR
Run
- Run the script:
python carbon-intelligence-amazon-dsp-export.py - Exported data appears in
OUTPUT_DIR - Schedule regular execution via
cron(Linux/macOS) or Task Scheduler (Windows)
What is exported
11 tabs created automatically
| Tab | Content | Usage Carbon Intelligence |
|---|---|---|
| CI_Campaigns | By order/line item + week | Emissions overview |
| CI_Device | Desktop, mobile, tablet, CTV, Fire Tablet | Energy factor per device |
| CI_Geo | By country and region | GMSF v1.2 country energy mix |
| CI_Placements | By inventory source | Energy-intensive placements |
| CI_CreativeSize | By creative size | Data transfer weight |
| CI_AdFormat | Display, Video, OLV, STV, Audio (Amazon formats) | Ad format factor |
| CI_Video | Detailed video data (duration, quartiles) | Video carbon calculation |
| CI_SupplySource | Amazon inventory vs 3rd party | 🎯 Amazon DSP Specific |
| CI_Environment | Delivery context | Delivery parameters |
| CI_Metadata | Account and export information | Traceability and audit |
| CI_Export_CSV | All dimensions consolidated | Direct 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™
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'
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
Website
carbonintelligence.green
Script version
1.0.0
Methodology
GMSF v1.2 (Ad Net Zero)