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
- Set up your development environment.
- Make sure you have properly annotated your API.
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:
Build your API
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
Unzip the file by using the unzip utility, or use another ZIP-compatible unarchiving utility:
unzip ./echo-v1-java.zip
Change directory:
cd echo
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 toecho-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 toecho-v1-1.23.0-SNAPSHOT.jar
.Add the client library JAR to your Java or Android app.
Repeat these steps every time you modify your API code.
What's next
- Call the backend API from an Android app.
- Learn more about Cloud Endpoints Frameworks for App Engine.