- Open Source
- APIs
- Advertising
- Blog
- Events
- Podcasts
- Apps
- Native
- Documentation
- Yahoo Native to Yahoo DSP API Migration Guide
- Sign In
- Language:
Create DSP Creative¶
The attached (downloadable) Zip file contains 8 code snippets demonstrating how to create DSP creatives and populate those creatives using Native (Gemini) ad assets.
You can download all 8 code snippets by clicking Create DSP Creative Java code snippets
.
For reference, in the DSP API a creative is an object that defines the image or video asset that is the foundation of an ad. A single creative may be used in many different ads. Every ad
is defined by a creative, which is identified by its creativeId
.
Java Code Snippets¶
Follow this coding sequence when creating DSP creatives and populating those creatives with Gemini ad assets:
1.``CreateDspCreative.java``. Begin like this:
// First call the Gemini API to get the Gemini ad payload
// GET https://api.gemini.yahoo.com/v3/rest/ad/{adId}
GeminiAd geminiAd = getGeminiAd(adId);
// Then map the Gemini ad to the DSP creative
DspCreative dspCreative = geminiAdToDspCreative(geminiAd);
// Now map the Gemini ad assets to the DSP creative
for (GeminiAdAsset geminiAdAsset : geminiAd.getAdAssets()) {
populateDspCreativeFromGeminiAsset(dspCreative, geminiAdAsset);
}
// Here you call the DSP API to create the creative
// POST /traffic/creatives
creativeService.add(dspcCreative);
2.``GeminiAdToDspCreative.java``. Use this snippet to populate the DSP creative using Gemini ad. 3.``GeminiAdAssetToDspCreative.java``. Use this to populate the DSP creative using Gemini ad assets. It calls functions 4.1-4.5 using an if else condition. 4.1.``GeminiCarouselAdAssetToDspCreative.java`` 4.2.``GeminiTouchpointsAdAssetToDspCreative.java`` 4.3.``GeminiTilesAdAssetToDspCreative.java`` 4.4.``PopulateMailSponsored.java`` 4.5.``PopulatePortrait.java``
Example |
Java code |
Demonstrates |
---|---|---|
Example 1 |
|
Shows a class that represents a Gemini targeting attribute. |
Example 2 |
|
Defines enumerations to represent Gemini targeting types, which include DEVICE, DAY_TIME, LOCATION, AGE, GENDER, and SEGMENT. |