This page describes how 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.

To create iOS clients for your API, we recommend that you use
[Google APIs Objective-C Client Library for REST APIs](https://github.com/google/google-api-objectivec-client-for-rest/wiki).

## Before you begin

- Download the Cloud Endpoints Frameworks library and tools into your app directory as described in [Getting started with Endpoints Frameworks](https://docs.cloud.google.com/endpoints/docs/frameworks/python/quickstart-frameworks-python).
- Make sure you have properly [decorated](https://docs.cloud.google.com/endpoints/docs/frameworks/python/create_api.md.txt) your API code with the expected frameworks code.

## Generating the client library

The following instructions demonstrate how to use the
Endpoints Frameworks
[command-line
tool](https://docs.cloud.google.com/endpoints/docs/frameworks/python/endpoints_tool) to generate a Gradle client bundle from the sample code from
[Getting started with Cloud Endpoints](https://docs.cloud.google.com/endpoints/docs/frameworks/python/quickstart-frameworks-python).

To generate a client library:

1. Change directory to the directory containing your API `app.yaml` file and
   API classes.

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

   ```python
   python 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.

   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
   ```
3. Unzip the file using the unzip utility, or use another ZIP-compatible
   unarchiving utility:

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

   ```python
   cd echo
   ```
5. Build the client library:

   ```python
   gradle build
   ```

   The output is in the `build/libs` directory. The exact filename depends
   on the version of the client. It is similar to
   `echo-v1-1.23.0-SNAPSHOT.jar`.
6. Add the client library JAR to your app.

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

## What's next

For information and sample code showing how to access a backend API from a
Python client, see
[Accessing backend APIs from Python clients](https://docs.cloud.google.com/endpoints/docs/frameworks/python/access_from_python.md.txt).