Cloud Endpoints Frameworks for App Engine Command Line Tool

This page describes how to use the Cloud Endpoints Frameworks command line tool to generate a client library from your Python backend API (the code that runs on the server). Any Java or Android app can use this library to call the API.

You can generate client library bundles that allow applications to access your API using the Cloud Endpoints Frameworks command line tool. When you generate a client library, the Frameworks command line tool automatically generates a Discovery document that describes the surface of your API.

The Frameworks command line tool,endpointscfg.py is available in the Cloud Endpoints Frameworks library. For information on installing the Endpoints Frameworks library using pip, see Installing the Endpoints Frameworks library. Note that the commands below assume you have installed the Endpoints Frameworks library in a directory called lib. Additionally, the instructions assume you have created your backend API. See the Endpoint Frameworks in Python tutorial for an example of using the Frameworks command line tool on sample code.

Generating a client library bundle from an API

You can use the Frameworks command line tool to generate the following types of client bundles:

  • Maven: This bundle includes a pom.xml file with the Endpoints Frameworks and Google API client dependencies. The readme.html provides detailed information on what you need to add to your pom.xml file for different types of client applications and how to build a client library for your API using Maven.

  • Gradle: This bundle includes a build.gradle file with the Endpoints Frameworks and Google API client dependencies. The readme.html provides detailed information on what you need to add to your build.gradle file for different types of client applications and how to build a client library for your API using Gradle.

  • default client bundle: This bundle contains all the dependency libraries and the generated source.jar file, which is the Java library that you use in your client to call your API. This bundle provides your client with all of the Google API client capabilities, including OAuth. The readme.html file lists the .jar files that are required for different types of client applications and other details for using the client library.

If you are using the client library with an Android app, we recommend that you use a Gradle client bundle.

Generating the client library

To generate the client library:

  1. Change directory to the directory containing your API's app.yaml file and API service classes. Alternatively, use the --application option to specify some other location of your application directory.

  2. Invoke the Endpoints command line tool similar to the following:

    lib/endpoints/endpointscfg.py get_client_lib java -bs gradle main.EchoApi
    

    where main is the class containing your API and EchoApi is your API name.

  3. Wait for the tool to generate the library; on success the tool displays a message similar to this one:

    API client library written to ./echo-v1.zip
    
  4. Add the client library JAR to your Android app.

  5. Repeat the above steps every time you modify your API code.

The client library bundle is written to the current directory unless you specify some other output directory using the output option.

Command line syntax

The basic syntax is as follows:

/path-to/your-app/lib/endpointscfg.py <command> <target_lang> <options> [class-name]

where:

  • <command> is get_client_lib.
  • <target-lang> (used only in get_client_lib) to specify the type of client bundle you want to create. Currently, you are required to supply the value java (for Java clients such as Android)
  • <options>, if supplied, is one or more items shown in the Options table
  • [class name] is the full class name of your API.

Options

You can use the following options:

Option Name Description Example
application By default, the tool generates from the backend API in the current directory.
If you want to generate using a different directory, specify the path to the directory containing the app.yaml and service classes that implement your API.
--application /my_path/my_api_dir
build-system Lets you specify which type of client bundle should be produced. Specify gradle for a Gradle client bundle for Android, maven for a Maven client bundle, or default (or simply omit this option) for a bundle that contains only the dependency libraries and source jar. --build-system=gradle
-bs gradle
hostname Specifies the discovery document rootURL.
This option overrides the default value derived from the application entry inside the backend API project app.yaml (<application>.appspot.com).
One use of this option is to supply the hostname localhost as the rootURL for local testing.
--hostname localhost
format Don't specify this because the only supported value is the default value, rest for REST. Not needed, use default.
output Sets the directory where the output will be written to.
Default: the directory the tool is invoked from.
--output /mydir
-o /mydir

Supported Client Platforms

The following platforms are supported in the client bundle produced by the Endpoints command line tool:

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Endpoints Frameworks for App Engine