rdfp v0.1.2

0

Monthly downloads

0th

Percentile

An Implementation of the 'DoubleClick for Publishers' API

An implementation of Google's 'DoubleClick for Publishers' (DFP) API <https://developers.google.com/doubleclick-publishers/docs/start>. This package is automatically compiled from the API WSDLs (Web Service Description Language) files to dictate how the API is structured. Theoretically, all API actions are possible using this package; however, care must be taken to format the inputs correctly and parse the outputs correctly as well. Please see Google's DFP API reference and this package's website <https://stevenmmortimer.github.io/rdfp/> for more information, documentation, and examples.

Readme

rdfp

Build Status AppVeyor Build Status CRAN\_Status\_Badge Coverage Status

Compiled using DFP API version: v201802

rdfp allows you to use the DoubleClick for Publishers API from R. Manage inventory, create orders, pull reports, and more!

Table of Contents

Installation

install.packages("devtools")

# or to get the latest version available on GitHub
devtools::install_github("StevenMMortimer/rdfp")

If you encounter a clear bug, please file a minimal reproducible example on GitHub.

Vignettes

The README below outlines the package functionality, but review the vignettes for more detailed examples on usage.

Usage

Functions

All functions start with dfp_ so that you can easily identify DFP-specific operations and use tab completion in RStudio. Most rdfp functions will return a data.frame or list parsed from the XML returned in the SOAP response.

Load Package and Set API Version

Google releases 4 versions of the DFP API each year and deprecates versions older than one year, so there is a lot that's regularly changing in this package. rdfp is periodically compiled against a recent version of the API. If you would like to use an older or newer API version that what is the package default, then just specify it as an option.

library(rdfp)
# see the package default version
getOption("rdfp.version")
#> [1] "v201802"
# this will force all calls to be against the version "v201711"
options(rdfp.version = "v201711")

Authenticate

To authenticate you will first need to specify the network_code of the DFP instance you'd like to connect to. This is the only required option that the user must specify when using the rdfp package. After setting the network_code all you need to do is run dfp_auth(). If you already have a cached .httr-oauth file in the current working directory, then the token will be loaded and refreshed if necessary. Otherwise, your browswer will pop open and you will interactively authenticate.

The package has other options like a client_id and client_secret where you can connect using your own API client instead of the package default. Using your own client requires setting one up in the [Google Developers Console] (https://console.developers.google.com).

options(rdfp.network_code = "12345678")
options(rdfp.application_name = "MyApp")
options(rdfp.client_id = "012345678901-99thisisatest99.apps.googleusercontent.com")
options(rdfp.client_secret = "Th1s1sMyC1ientS3cr3t")

# this function will use the options set above and 
# cache an OAuth token in the working directory
# the token will be refreshed when necessary
dfp_auth()

Get Current User Info

# Check current user or network
user_info <- dfp_getCurrentUser()
user_info[,c('id', 'isActive')]
#> # A tibble: 1 x 2
#>           id isActive
#>        <dbl> <chr>   
#> 1 185549536. true
network_info <- dfp_getCurrentNetwork()
network_info[,c('id', 'networkCode')]
#> # A tibble: 1 x 2
#>        id networkCode
#>     <dbl>       <dbl>
#> 1 109096.    1019096.

Pull a LineItem

The function dfp_getLineItemsByStatement() function from the LineItemService allows you to retrieve Line Items by Publishers Query Language (PQL) statement. The statement is constructed as a list of lists that are nested to emulate the hierarchy of the XML that needs to be created in the request.

# Retrieve up to 3 Line Items that have a status of "DELIVERING"
request_data <- list('filterStatement'=list('query'="WHERE status='DELIVERING' LIMIT 3"))
resultset <- dfp_getLineItemsByStatement(request_data, as_df=TRUE) 
resultset[,c('orderId', 'id', 'priority', 'deliveryRateType')]
#> # A tibble: 3 x 4
#>       orderId          id priority deliveryRateType
#>         <dbl>       <dbl>    <dbl> <chr>           
#> 1 1254227776. 1928427256.      12. EVENLY          
#> 2 1393728736. 2038280896.      12. EVENLY          
#> 3 1265251936. 2060032216.      16. EVENLY

Run a Report

Below is an example of how to make a simple report request.

# In order to run a report you must specify how the report should be structured 
# by specifying a reportQuery inside a reportJob. All of the dimensions, columns, 
# date range options, etc. are documented at:
# https://developers.google.com/doubleclick-publishers/docs/reference/v201802/ReportService.ReportQuery
request_data <- list(reportJob=list(reportQuery=list(dimensions='MONTH_AND_YEAR', 
                                                     dimensions='AD_UNIT_ID',
                                                     adUnitView='FLAT',
                                                     columns = 'AD_SERVER_IMPRESSIONS', 
                                                     columns = 'AD_SERVER_CLICKS',
                                                     dateRangeType='LAST_WEEK'
                                                     )))

# a convenience function has been provided to you to manage the report process workflow
# if you would like more control, see the example below which moves through each step in the process
report_data <- dfp_full_report_wrapper(request_data)
report_data[,c('Dimension.MONTH_AND_YEAR', 'Dimension.AD_UNIT_ID', 'Column.AD_SERVER_CLICKS')]
#> # A tibble: 25 x 3
#>    Dimension.MONTH_AND_YEAR Dimension.AD_UNIT_ID Column.AD_SERVER_CLICKS
#>    <chr>                                   <dbl>                   <dbl>
#>  1 2018-03                            133765096.                   1778.
#>  2 2018-03                            133765216.                    422.
#>  3 2018-03                            133765336.                    642.
#>  4 2018-03                            133765456.                   2176.
#>  5 2018-03                            142461136.                     91.
#>  6 2018-03                            133765576.                  17581.
#>  7 2018-03                            133765696.                    945.
#>  8 2018-03                            133765936.                  18171.
#>  9 2018-03                            142461016.                    312.
#> 10 2018-03                            143543776.                   1496.
#> # ... with 15 more rows

Credits

This application uses other open source software components. The authentication components are mostly verbatim copies of the routines established in the googlesheets package (https://github.com/jennybc/googlesheets). We acknowledge and are grateful to these developers for their contributions to open source.

More Information

Google provides support for client libraries here, but unfortunately, R is not a supported language. Google's client libraries directly reference the production WSDLs to interact with the API, but this package makes SOAP requests best formatted to match the WSDL standards. This articulation is not perfect and continued progress will be made to bring functionality up to par with the client libraries.

Most all operations supported by the DFP API are available via this package. It is strongly recommended that you use the DFP API Reference when using this package. Details on formatting, attributes, and methods are all better explained by Google's documentation.

More information is also available on the pkgdown site at https://StevenMMortimer.github.io/rdfp/.

Top


Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Functions in rdfp

Name Description
dfp_createCreativeWrappers CreativeWrapperService
dfp_createCreatives CreativeService
dfp_createCustomTargetingKeys CustomTargetingService
dfp_createNativeStyles NativeStyleService
dfp_createContentBundles ContentBundleService
dfp_createCustomTargetingValues createCustomTargetingValues
dfp_createProductPackages ProductPackageService
dfp_createOrders OrderService
dfp_createProductTemplates ProductTemplateService
dfp_createProposalLineItems ProposalLineItemService
dfp_full_report_wrapper Take report request and return data.frame
dfp_getAvailabilityForecast ForecastService
dfp_createProducts ProductService
dfp_getActivitiesByStatement getActivitiesByStatement
dfp_getAvailabilityForecastById getAvailabilityForecastById
dfp_getCurrentNetwork getCurrentNetwork
dfp_createMobileApplications MobileApplicationService
dfp_createPlacements PlacementService
dfp_createLiveStreamEvents LiveStreamEventService
dfp_createPackages PackageService
dfp_getCurrentUser getCurrentUser
dfp_createExchangeRates ExchangeRateService
dfp_getActivityGroupsByStatement getActivityGroupsByStatement
dfp_getCustomTargetingKeysByStatement getCustomTargetingKeysByStatement
dfp_getAdRulesByStatement getAdRulesByStatement
dfp_createLabels LabelService
dfp_getCustomTargetingValuesByStatement getCustomTargetingValuesByStatement
dfp_getOrdersByStatement getOrdersByStatement
dfp_createLineItemCreativeAssociations LineItemCreativeAssociationService
dfp_getPreviewUrlsForNativeStyles getPreviewUrlsForNativeStyles
dfp_getNativeStylesByStatement getNativeStylesByStatement
dfp_getProductPackageItemsByStatement getProductPackageItemsByStatement
dfp_getAllNetworks NetworkService
dfp_getAdExclusionRulesByStatement getAdExclusionRulesByStatement
dfp_getReconciliationReportRowsByStatement ReconciliationReportRowService
dfp_getAdUnitSizesByStatement getAdUnitSizesByStatement
dfp_createProposals ProposalService
dfp_getContactsByStatement getContactsByStatement
dfp_getAdUnitsByStatement getAdUnitsByStatement
dfp_getCompaniesByStatement getCompaniesByStatement
dfp_getContentByStatementAndCustomTargetingValue getContentByStatementAndCustomTargetingValue
dfp_getReconciliationReportsByStatement ReconciliationReportService
dfp_getLineItemCreativeAssociationsByStatement getLineItemCreativeAssociationsByStatement
dfp_getContentBundlesByStatement getContentBundlesByStatement
dfp_createLineItems LineItemService
dfp_getContentMetadataKeyHierarchiesByStatement getContentMetadataKeyHierarchiesByStatement
dfp_getContentByStatement ContentService
dfp_createPremiumRates PremiumRateService
dfp_getLineItemTemplatesByStatement LineItemTemplateService
dfp_performAdExclusionRuleAction performAdExclusionRuleAction
dfp_performAdRuleAction performAdRuleAction
dfp_createRateCards RateCardService
dfp_getLineItemsByStatement getLineItemsByStatement
dfp_getDeliveryForecast getDeliveryForecast
dfp_performMobileApplicationAction performMobileApplicationAction
dfp_createProductPackageItems ProductPackageItemService
dfp_createTeams TeamService
dfp_createUsers UserService
dfp_date_to_list Format a datetime for DFP
dfp_getBaseRatesByStatement getBaseRatesByStatement
dfp_getLiveStreamEventsByStatement getLiveStreamEventsByStatement
dfp_performNativeStyleAction performNativeStyleAction
dfp_createUserTeamAssociations UserTeamAssociationService
dfp_getProposalsByStatement getProposalsByStatement
dfp_getCdnConfigurationsByStatement getCdnConfigurationsByStatement
dfp_getAllRoles getAllRoles
dfp_getAudienceSegmentsByStatement getAudienceSegmentsByStatement
dfp_performOrderAction performOrderAction
dfp_getRateCardsByStatement getRateCardsByStatement
dfp_getReportDownloadURL ReportService
dfp_getCreativeSetsByStatement getCreativeSetsByStatement
dfp_getCreativeTemplatesByStatement CreativeTemplateService
dfp_getCreativeWrappersByStatement getCreativeWrappersByStatement
dfp_getCustomFieldOption getCustomFieldOption
dfp_getDeliveryForecastByIds getDeliveryForecastByIds
dfp_getPackagesByStatement getPackagesByStatement
dfp_getCreativesByStatement getCreativesByStatement
dfp_performPackageAction performPackageAction
dfp_getReportDownloadUrlWithOptions getReportDownloadUrlWithOptions
dfp_getPlacementsByStatement getPlacementsByStatement
dfp_getExchangeRatesByStatement getExchangeRatesByStatement
dfp_getCustomFieldsByStatement getCustomFieldsByStatement
dfp_registerSessionsForMonitoring registerSessionsForMonitoring
dfp_getLabelsByStatement getLabelsByStatement
dfp_getProductPackagesByStatement getProductPackagesByStatement
dfp_getProductTemplatesByStatement getProductTemplatesByStatement
dfp_getReportJobStatus getReportJobStatus
dfp_getMarketplaceCommentsByStatement getMarketplaceCommentsByStatement
dfp_getPremiumRatesByStatement getPremiumRatesByStatement
dfp_report_url_to_dataframe Take report URL and convert to data.frame
dfp_performBaseRateAction performBaseRateAction
dfp_getPreviewUrl getPreviewUrl
dfp_performContentBundleAction performContentBundleAction
dfp_getReconciliationOrderReportsByStatement ReconciliationOrderReportService
dfp_getReconciliationLineItemReportsByStatement ReconciliationLineItemReportService
dfp_updateActivityGroups updateActivityGroups
dfp_getSavedQueriesByStatement getSavedQueriesByStatement
dfp_getUserTeamAssociationsByStatement getUserTeamAssociationsByStatement
dfp_getMobileApplicationsByStatement getMobileApplicationsByStatement
dfp_updateAdExclusionRules updateAdExclusionRules
dfp_performLabelAction performLabelAction
dfp_getProductsByStatement getProductsByStatement
dfp_performContentMetadataKeyHierarchyAction performContentMetadataKeyHierarchyAction
dfp_getProposalLineItemsByStatement getProposalLineItemsByStatement
dfp_performLineItemAction performLineItemAction
dfp_getSuggestedAdUnitsByStatement SuggestedAdUnitService
dfp_performProductTemplateAction performProductTemplateAction
dfp_performCreativeWrapperAction performCreativeWrapperAction
dfp_updateContentMetadataKeyHierarchies updateContentMetadataKeyHierarchies
dfp_performProposalAction performProposalAction
dfp_getTeamsByStatement getTeamsByStatement
dfp_getWorkflowRequestsByStatement WorkflowRequestService
dfp_performCustomTargetingValueAction performCustomTargetingValueAction
dfp_updateCreativeSet updateCreativeSet
dfp_performExchangeRateAction performExchangeRateAction
dfp_performLineItemCreativeAssociationAction performLineItemCreativeAssociationAction
dfp_makeTestNetwork makeTestNetwork
dfp_performReconciliationOrderReportAction performReconciliationOrderReportAction
dfp_performProposalLineItemAction performProposalLineItemAction
dfp_performSuggestedAdUnitAction performSuggestedAdUnitAction
dfp_performLiveStreamEventAction performLiveStreamEventAction
dfp_getUsersByStatement getUsersByStatement
dfp_updateLiveStreamEvents updateLiveStreamEvents
dfp_updateCdnConfigurations updateCdnConfigurations
dfp_updateMobileApplications updateMobileApplications
dfp_performRateCardAction performRateCardAction
dfp_performTeamAction performTeamAction
dfp_performAdUnitAction performAdUnitAction
dfp_performCustomFieldAction performCustomFieldAction
dfp_updateProposalLineItems updateProposalLineItems
dfp_performAudienceSegmentAction performAudienceSegmentAction
dfp_performProductAction performProductAction
dfp_performPlacementAction performPlacementAction
dfp_updateCompanies updateCompanies
dfp_performUserTeamAssociationAction performUserTeamAssociationAction
dfp_performUserAction performUserAction
dfp_updateContacts updateContacts
dfp_performCustomTargetingKeyAction performCustomTargetingKeyAction
dfp_updateAudienceSegments updateAudienceSegments
dfp_performWorkflowRequestAction performWorkflowRequestAction
dfp_performProductPackageAction performProductPackageAction
dfp_performProductPackageItemAction performProductPackageItemAction
dfp_updateProposals updateProposals
dfp_updateContentBundles updateContentBundles
dfp_updateBaseRates updateBaseRates
dfp_select_parse Take select request and return data.frame
execute_soap_request Transmit and Receive API SOAP Calls
form_request_body Format SOAP Request Body
token_exists Check if authorization currently in force
dfp_updateCustomFieldOptions updateCustomFieldOptions
dfp_updateActivities updateActivities
dfp_runReportJob runReportJob
xmlToList2 xmlToList2
dfp_updateLabels updateLabels
dfp_updateNetwork updateNetwork
dfp_updateExchangeRates updateExchangeRates
dfp_updateCreatives updateCreatives
dfp_updateProductPackageItems updateProductPackageItems
dfp_updateProductPackages updateProductPackages
is_legit_token Check that token appears to be legitimate
dfp_updateRateCards updateRateCards
dfp_updateCreativeWrappers updateCreativeWrappers
dfp_updateNativeStyles updateNativeStyles
xml_nodeset_to_df xml_nodeset_to_df
get_google_token Retrieve Google token from environment
dfp_select PublisherQueryLanguageService
dfp_updateCustomFields updateCustomFields
dfp_updateOrders updateOrders
dfp_updateUserTeamAssociations updateUserTeamAssociations
parse_soap_response Parse SOAP Response Body
dfp_updateReconciliationLineItemReports updateReconciliationLineItemReports
rdfp rdfp package
dfp_updateAdRules updateAdRules
dfp_updateCustomTargetingKeys updateCustomTargetingKeys
dfp_updateProducts updateProducts
dfp_updateUsers updateUsers
dfp_updateAdUnits updateAdUnits
dfp_updateCustomTargetingValues updateCustomTargetingValues
dfp_updatePackages updatePackages
dfp_updateProductTemplates updateProductTemplates
dfp_updateReconciliationOrderReports updateReconciliationOrderReports
dfp_updateLineItemCreativeAssociations updateLineItemCreativeAssociations
dfp_updateLineItems updateLineItems
dfp_updateReconciliationReportRows updateReconciliationReportRows
dfp_updatePlacements updatePlacements
dfp_updatePremiumRates updatePremiumRates
dfp_updateReconciliationReports updateReconciliationReports
dfp_updateTeams updateTeams
dfp_createBaseRates BaseRateService
dfp_createActivityGroups ActivityGroupService
dfp_createAdUnits InventoryService
dfp_createAdRules AdRuleService
build_xml_from_list Build XML Request Body
dfp_createAudienceSegments AudienceSegmentService
dfp_createActivities ActivityService
dfp_createCreativeSet CreativeSetService
dfp_auth Authorize rdfp
catch_errors Function to catch and print HTTP errors
dfp_createAdExclusionRules AdExclusionRuleService
dfp_createContentMetadataKeyHierarchies ContentMetadataKeyHierarchyService
dfp_createCustomFieldOptions CustomFieldService
dfp_createCustomFields createCustomFields
dfp_createCompanies CompanyService
dfp_createCdnConfigurations CdnConfigurationService
dfp_createContacts ContactService
No Results!

Vignettes of rdfp

Name
ad-trafficking-setup.Rmd
administrative-tasks.Rmd
checking-availability.Rmd
manipulating-orders-and-lineitems.Rmd
pulling-reports.Rmd
No Results!

Last month downloads

Details

Date 2018-04-05
URL https://github.com/StevenMMortimer/rdfp
BugReports https://github.com/StevenMMortimer/rdfp/issues
Encoding UTF-8
License MIT + file LICENSE
LazyData true
RoxygenNote 6.0.1
Collate 'ActivityGroupService.R' 'ActivityService.R' 'AdExclusionRuleService.R' 'AdRuleService.R' 'AudienceSegmentService.R' 'BaseRateService.R' 'CdnConfigurationService.R' 'CompanyService.R' 'ContactService.R' 'ContentBundleService.R' 'ContentMetadataKeyHierarchyService.R' 'ContentService.R' 'CreativeService.R' 'CreativeSetService.R' 'CreativeTemplateService.R' 'CreativeWrapperService.R' 'CustomFieldService.R' 'CustomTargetingService.R' 'ExchangeRateService.R' 'ForecastService.R' 'InventoryService.R' 'LabelService.R' 'LineItemCreativeAssociationService.R' 'LineItemService.R' 'LineItemTemplateService.R' 'LiveStreamEventService.R' 'MobileApplicationService.R' 'NativeStyleService.R' 'NetworkService.R' 'OrderService.R' 'PackageService.R' 'PlacementService.R' 'PremiumRateService.R' 'ProductPackageItemService.R' 'ProductPackageService.R' 'ProductService.R' 'ProductTemplateService.R' 'ProposalLineItemService.R' 'ProposalService.R' 'PublisherQueryLanguageService.R' 'RateCardService.R' 'ReconciliationLineItemReportService.R' 'ReconciliationOrderReportService.R' 'ReconciliationReportRowService.R' 'ReconciliationReportService.R' 'ReportService.R' 'SuggestedAdUnitService.R' 'TeamService.R' 'UserService.R' 'UserTeamAssociationService.R' 'WorkflowRequestService.R' 'dfp_auth.R' 'dfp_options_settings.R' 'dfp_service_endpoints.R' 'dfp_utils.R' 'dfp_utils_xml.R' 'rdfp.R'
VignetteBuilder knitr
NeedsCompilation no
Packaged 2018-04-07 01:22:11 UTC; steven.mortimer
Repository CRAN
Date/Publication 2018-04-09 11:08:29 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/rdfp)](http://www.rdocumentation.org/packages/rdfp)