Python Quickstart

To demonstrate the functionality of the App Engine Administration API, a sample Python client is provided. This example retrieves a list of applications, a list of modules for each app, and a list of versions for each of those modules.

Enable access to the API

You will need to enable access to the API for a Cloud project. Visit the Google Cloud Platform Console. Click on the name of the project which you would like to use.

Enable the App Engine Admininistration API.

Enable the API

Authenticate with the Google Cloud SDK

This sample obtains authentication information from its environment via application default credentials by calling GoogleCredentials.get_application_default().

If you're running the sample on App Engine or Compute Engine, the environment is already authenticated as a service account, so you can skip this step. Otherwise, you'll first have to initialize your environment with credentials the sample can use.

The easiest way to do this is to use the Google Cloud SDK. On Linux/Mac OS X, you can install via:

$ curl | bash

Once installed, authenticate your environment by running:

$ gcloud auth login

Sample code

Note: Download and install the Google APIs Client Library for Python if it is not installed on your machine.

Save the following code to a file in the same directory as the JSON file:

# Copyright 2013 Google Inc. All Rights Reserved.

"""Demo client for the Google App Engine Administration API.

This sample client demonstrates how to use the API and manipulate
apps deployed on Google App Engine.

__author__ = ' (Sarmad Gilani)'

from oauth2client.client import GoogleCredentials
from googleapiclient.discovery import build

def main():
  # Authenticate and construct service.
  service = build('appengine', 'v1beta2',

  # Get a list of your applications.
  response = service.apps().list().execute()
  apps_list = response.get('apps', [])

  for app in apps_list:
    print 'App Title: ', app['title']
    print 'App ID: ', app['appId']

    # List all modules on the application.
    response = service.apps().modules().list(
    modules_list = response.get('modules', [])

    print '  Modules for this app:'
    for module in modules_list:
      print '    Module ID: ', module['moduleId']

      # List all versions on this module.
      response = service.apps().modules().versions().list(
      versions_list = response.get('versions', [])

      print '      Versions on this module: '
      for version in versions_list:
        print '        Version ID: ', version['versionId']
        print '        Runtime: ', version['runtime']
        print '        Deployment Timestamp: ', version['deployedTimestamp']
        if version['isDefault']:
          print '        ** This is the default version. **'

if __name__ == '__main__':

Send feedback about...

Google App Engine Admin API v1beta2