(Translated by https://www.hiragana.jp/)
Google Ads Developer Blog: test_network



Today, we’d like to present the new DFP API Playground for test networks, built on Google App Engine using the new ads Java client library.

What’s New
  • Test networks can be created using the playground application
  • OAuth2.0 authentication using the Java client library with automatic token refresh
  • Uses a push queue to make API calls in background tasks and stream results back using the Channel API
Please note that the playground only makes test networks accessible, so you will not be able to view production or old sandbox networks through the application. We’ve made the project open-sourced so you can get more details on integrating DFP API with App Engine through the project repository.

Test Network Creation
The new playground makes it simple for API developers to create test networks and get started with DFP API. All you have to do is log in with a Google account that’s not already associated with a test network and you will be prompted to create a new one.

1. Visit http://dfp-playground.appspot.com/. You’ll be asked to sign in with your account if you haven’t already done so.

2. Authorize the application to make requests to DFP API on your behalf (you’ll only have to do this once).



3. Click the “Create Test Network” button.



4. And you’re done! You can now configure your test network (language, currency, etc) by following the link to the DFP user interface.



We are always looking for ways to help API developers be more productive, so if there are any features you would like to see in the playground application or in the API, please leave us a comment at our forum. We’d also love to chat with you at one of our Office hours hangouts.

We announced in a previous post an easier way to test with the DFP API. We've iterated quickly and improved on that solution and we are also setting a date for the shutdown of the sandbox.

Test Accounts
When we initially launched the new test networks, you had to create a new Google account if you had any type of DFP network associated with the account. We've lifted this restriction. Now each Google account is always allowed to create a single test network using NetworkService.makeTestNetwork(). This means you can use the same google account for production and test networks.

Sandbox Shutdown
Now that we've given you a bit of time to switch off of the sandbox environment, we're announcing that we are shutting it down on May 24th, 2012. This allows for another month of testing, but we hope you will migrate to the new test networks as soon as possible.

Happy testing and stay tuned for more DFP API blog posts. Don't forget to join us on our next Hangout and, as always, let us know if you want to see any new features or blog posts on our forum.


With the addition of the new test networks to replace the sandbox environment networks, we’d like to do a review of how to test your forecasting on test networks. Since the test networks don’t serve ads, you have no traffic history to provide forecasting data. Instead, the API returns predictable results in the Forecast object so you can effectively test your application.

Forecast Service with Test Networks

The forecast service can be used by calling getForecast with a new line item or getForecastById with the ID of an existing line item. In production, these calls will tell you whether you can expect the line item to deliver the booked clicks/impressions based on how your network’s done in the past. In the test network, the only two parameters that affect the forecast results are the lineItemType and unitsBought fields on the line item. The expected responses are summarized below and in our documentation.

Input (Line Item Field) Output (Forecast Field)
lineItemType unitsBought availableUnits forecastUnits
(matchedUnits)
deliveredUnits
Sponsorship 50 1,200,000 6,000,000 600,000
prospective: 0
Sponsorship != 20 and != 50 1,200,000 1,200,000 600,000
prospective: 0
Not Sponsorship <= 1,000,000 unitsBought * 2 availableUnits * 3 600,000
prospective: 0
Not Sponsorship > 1,000,000 unitsBought * 2 availableUnits * 3 600,000
prospective: 0

It is a good idea to include a test case where the forecasting service throws an exception so your application can handle error conditions correctly. You can trigger the service to throw a SERVER_NOT_AVAILABLE error by setting the line item type to sponsorship and the units bought to exactly 20.

Dealing with Production Quota

In addition, please be mindful that in production (as opposed to test networks), forecasting is a resource intensive process on the server and too many back-to-back requests may cause the API to throw an EXCEEDED_QUOTA error. When this occurs, we recommend backing off briefly before retrying to bring the requests per second down. Recall that the quotas are based on the number of requests per second rather than an absolute number of requests. You are less likely to get rate limited by the API with a steady stream of requests rather than with short bursts of many requests.

We appreciate any feedback from you regarding features you’d like us to highlight or about the API in general. Please don’t hesitate to leave us a suggestion on our forum or come chat with us at one of our DFP API Office Hours Hangouts.

We are pleased to announce a better way to develop and test your code with the DFP API. In v201203 you now have the ability to create a test network through a few easy steps. As an added bonus, you can now access the new test and production networks via the normal login screen. Read below for more information on the new self-service way of creating a development test environment for the API.

Create a Google Account
You'll first need a new Google account since you are only allowed one test network per email address. You'll use this account to authenticate with the API when creating the test network. There is no need to worry about your other DFP accounts and whether they have been linked, you only need a valid Google account.

Setup Your Client Library
As stated earlier, this feature is only available in the API so you'll need to set up your preferred client library in your development environment.

Execute the Example Code
Each of the client libraries has an example that you can run with your Google account credentials. This sample code executes the NetworkService.makeTestNetwork() service to create the network. After running this, your network will be ready to use and you will get a printout similar to the message below.

If you instead receive an error with the message
AuthenticationError.GOOGLE_ACCOUNT_ALREADY_ASSOCIATED_WITH_NETWORK
you will need to create a new Google account and try again.

Differences for the Test Network
A test network differs from a production network; in particular, a test network does not serve ads and can not be used in conjunction with any ad tags. As a result, the ForecastService provides mock forecasting information as specified in the documentation. Lastly, a test network offers only small business account features. If you need access to DFP Premium features contact your account manager for assistance.

Client Libraries
Once you've made the transition to a new test network you will no longer need to use the sandbox options in the client libraries. The new test networks utilize the same API endpoint as your production network so you only have to change your credentials and network code when preparing your code for a production release.

Sandbox Deprecation
In the coming months we will be phasing out support for the sandbox networks. Please take the time to migrate to a test network to ensure your testing is not interrupted.

Stay tuned for more DFP API blog posts including one discussing forecasting in the test networks. As always, let us know if you want to see any new features or blog posts on our forum.