Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta página, se describe cómo generar una biblioteca cliente desde tu API de backend de Python (el código que se ejecuta en el servidor). Cualquier aplicación para Java o Android puede usar esta biblioteca para llamar a la API.
Descarga la biblioteca y las herramientas de Cloud Endpoints Frameworks en el directorio de tu aplicación como se describe en Comenzar a usar Endpoints Frameworks.
Asegúrate de haber decorado correctamente tu código API con el código de Frameworks esperado.
donde main es la clase que contiene la API y EchoApi es el nombre de tu API.
Espera a que la herramienta genere la biblioteca; cuando lo logre, la herramienta mostrará un mensaje como este:
API client library written to ./echo-v1.zip
Descomprime el archivo con la utilidad de descompresión, o usa otra utilidad de extracción compatible con ZIP:
unzip./echo-v1-java.zip
Cambia el directorio:
cdecho
Compila la biblioteca cliente:
gradlebuild
El resultado está en el directorio build/libs. El nombre exacto del archivo depende de la versión del cliente. Será similar a echo-v1-1.23.0-SNAPSHOT.jar.
Agrega el JAR de la biblioteca cliente a tu app.
Repite estos pasos cada vez que modificas el código de la API.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[[["\u003cp\u003eThis guide explains how to generate a Java client library from a Python backend API, which enables Java and Android applications to interact with the API.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves using the Endpoints Frameworks command-line tool to create a Gradle client bundle from your API code, using the class and name of your API.\u003c/p\u003e\n"],["\u003cp\u003eOnce the client library is generated as a ZIP file, it must be unzipped, built using Gradle, and the resulting JAR file added to the Java or Android application.\u003c/p\u003e\n"],["\u003cp\u003eIt is important to repeat the library generation process whenever modifications are made to the backend API code to ensure the client library remains in sync with the server code.\u003c/p\u003e\n"],["\u003cp\u003eFor generating iOS clients for your API, Google APIs Objective-C Client Library for REST APIs is recommended, it is also possible to access backend API from a Python client.\u003c/p\u003e\n"]]],[],null,["# Generating a client library\n\nThis page describes how to generate a client library from your Python backend\nAPI (the code that runs on the server). Any Java or Android app can use this\nlibrary to call the API.\n\nTo create iOS clients for your API, we recommend that you use\n[Google APIs Objective-C Client Library for REST APIs](https://github.com/google/google-api-objectivec-client-for-rest/wiki).\n\nBefore you begin\n----------------\n\n- Download the Cloud Endpoints Frameworks library and tools into your app directory as described in [Getting started with Endpoints Frameworks](/endpoints/docs/frameworks/python/quickstart-frameworks-python).\n- Make sure you have properly [decorated](/endpoints/docs/frameworks/python/create_api) your API code with the expected frameworks code.\n\nGenerating the client library\n-----------------------------\n\nThe following instructions demonstrate how to use the\nEndpoints Frameworks\n[command-line\ntool](/endpoints/docs/frameworks/python/endpoints_tool) to generate a Gradle client bundle from the sample code from\n[Getting started with Cloud Endpoints](/endpoints/docs/frameworks/python/quickstart-frameworks-python).\n\nTo generate a client library:\n\n1. Change directory to the directory containing your API `app.yaml` file and\n API classes.\n\n2. Run the Endpoints command-line tool similar to the following:\n\n python lib/endpoints/endpointscfg.py get_client_lib java -bs gradle main.EchoApi\n\n where `main` is the class containing your API and `EchoApi` is your API name.\n\n Wait for the tool to generate the library; on success the tool displays a\n message similar to this one: \n\n ```\n API client library written to ./echo-v1.zip\n ```\n3. Unzip the file using the unzip utility, or use another ZIP-compatible\n unarchiving utility:\n\n unzip ./echo-v1-java.zip\n\n4. Change directory:\n\n cd echo\n\n5. Build the client library:\n\n gradle build\n\n The output is in the `build/libs` directory. The exact filename depends\n on the version of the client. It is similar to\n `echo-v1-1.23.0-SNAPSHOT.jar`.\n6. Add the client library JAR to your app.\n\n7. Repeat these steps every time you modify your API code.\n\nWhat's next\n-----------\n\nFor information and sample code showing how to access a backend API from a\nPython client, see\n[Accessing backend APIs from Python clients](/endpoints/docs/frameworks/python/access_from_python)."]]