Generating a client library

This page describes how to generate a client library from your backend API. Any Java or Android app can use this library to call the API.

To create iOS clients for your API, we recommend that you use Google APIs Objective-C Client Library for REST APIs.

Before you begin

Generating the client library

The following instructions demonstrate how to use the Cloud Endpoints Frameworks Apache Maven and Gradle plugins to generate a Gradle client bundle from the sample Maven project Getting started with Endpoints.

To generate a client library:

  1. Build your API

  2. Run the Endpoints Frameworks command-line tool similarly to the following:

    Maven

    mvn endpoints-framework:clientLibs

    Gradle

    gradle endpointsClientLibs

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

    Maven

    API client library written to target/client-libs/echo-v1-java.zip

    Gradle

    API client library written to build/endpointsClientLibs/echo-v1-java.zip
  3. Unzip the file by using the unzip utility, or use another ZIP-compatible unarchiving utility:

    unzip ./echo-v1-java.zip
    
  4. Change directory:

    cd echo
    
  5. Build the client library:

    Maven

    mvn clean package

    The output is in the target/ directory. The exact filename depends on the version of the Java client. It is something similar to echo-v1-1.23.0-SNAPSHOT.jar.

    Gradle

    gradle build

    The output is in the build/libs directory. The exact filename depends on the version of the Java client. It is something similar to echo-v1-1.23.0-SNAPSHOT.jar.

  6. Add the client library JAR to your Java or Android app.

  7. Repeat these steps every time you modify your API code.

What's next