My favorites | English | Sign in

AdSense API v3 Migration Guide

This article covers differences between v2 and v3 of the AdSense API. For solutions to frequently encountered migration issues, see the AdSense API v3 Migration Issues article. You can also find sample code for new and changed operations on the v3 Sample Code page.

General Changes

The following changes affect all AdSense API web services:

Endpoints

Version 3 services are located at a different URL. To access them, change your endpoints to the following URL:

https://google.com/api/adsense/v3/SERVICE_NAME

Namespaces

In addition to the new endpoint URLs, v3 uses a different XML namespace:

http://www.google.com/api/adsense/v3

Enumeration structure

Changes to the AdSense API back-end have altered the way that enumerated types are specified. (Enumerated types are shown in the Developer Guide as a constrained set of values.) In v3, enumerated types in parameters and response objects are represented by a string enclosed in a <value/> element.

In v2, you specified an enumerated parameter with the following XML:

<adUnitType>TextOnly</adUnitType>

In v3, you enclose the enumerated value in a <value/> element, as shown below:

<adUnitType><value>TextOnly</value></adUnitType>

For a list of all enumerated types in AdSense API, see the Appendix.

AccountService Changes

Use these tips to migrate your code that accesses AccountService.

  • Use createAccount instead of createAdSenseAccount

    createAccount acccepts a new parameter (developerUrl) and removes hasAcceptedTCs.

  • Use associateAccount instead of associateExistingAccount

    associateAccount also accepts developerUrl.

Caution: Even though createAdSenseAccount and associateExistingAccount are still available in v3, these requests have been deprecated and will be removed in a future version of the API.

AdSenseForContentService Changes

generateAdCode now accepts two new parameters:

  • cornerStyles

    The corner style that should be used for the requested ad unit

  • hostChannelName

    The AFC host channel that should be used to track statistics for this page.

Appendix: Enumerated Types

This appendix lists all enumerated types in AdSense API. To migrate to v3, you will need to modify your code to handle the enclosing <value/> element, as described in the General Changes section.

Tip: Frequently used requests are highlighted in the tables below.

AccountService

Enumerated Type Used in these requests: Used in these data objects:
ApprovalStatus getApprovalStatus PublisherApprovalStatus
EntityType
  • createAccount
  • getEntityType
(none)
MpmStatus getAssociationStatus PublisherAssociationStatus
SyndicationService_Type
  • addSyndicationService
  • associateAccount
  • createAccount
  • getAllSyndicationServices
  • getSupportedWebsiteLocalesForSyndicationService
  • getSyndicationService
SyndicationService_Data

AdSenseForContentService

Enumerated Type Used in these requests: Used in these data objects:
AdLayout
  • generateAdCode
  • getAdLayouts
  • getAdUnitTypes
  • getAllAdLayouts
(none)
AdUnitType
  • generateAdCode
  • getAdLayouts
  • getAdUnitTypes
  • getAllAdUnitTypes
(none)
ChannelService_Type
  • getActiveChannels
  • getChannels
  • getInactiveChannels
(none)
CornerStyles generateAdCode (none)

AdSenseForSearchService

,
Enumerated Type Used in these requests: Used in these data objects:
ChannelService_Type getChannels ChannelService_Data
ChannelService_Status getChannels ChannelService_Data
LogoPlacement
  • getBuiltinSearchResultStyles
  • getSearchResultStyles
  • saveSearchResultStyle
  • saveSearchResultStyles
SearchResultStyle
LogoType generateSearchBoxCode SearchBoxStyle
SearchTypegenerateSearchBoxCode

ChannelService

Enumerated Type Used in these requests: Used in these data objects:
ChannelService_Status
  • createChannel
  • createChannels
  • getChannel
  • getChannelCode
  • getChannels
  • updateChannel
  • updateChannels
ChannelService_Data
ChannelService_Type
  • createChannel
  • createChannels
  • getChannel
  • getChannelCode
  • getChannels
  • updateChannel
  • updateChannels
ChannelService_Data
SyndicationService_Type getSyndicationService SyndicationService_Data

ReportService

Enumerated Type Used in these requests: Used in these data objects:
Grouping generateReport
  • AFCChannelReport
  • AFSChannelReport
PredefinedDateRange generateReport DateRange
OutputFormat generateReport (all Report types)
Unit generateReport
  • AFCAggregateReport
  • AFCChannelReport
  • AFCSiteReport

SiteFilterService

SiteFilterService does not use any enumerated types.