Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara membuat library klien dari API backend
Python (kode yang berjalan di server). Setiap aplikasi Java atau Android dapat menggunakan library
ini untuk memanggil API.
Download library dan alat Cloud Endpoints Frameworks ke direktori aplikasi Anda seperti yang dijelaskan dalam Memulai Endpoints Frameworks.
Pastikan Anda telah
mendekorasi kode API dengan
kode framework yang diharapkan dengan benar.
Membuat library klien
Petunjuk berikut menunjukkan cara menggunakan
alat
command line Endpoints Framework untuk membuat paket klien Gradle dari kode contoh dari
Memulai Cloud Endpoints.
Untuk membuat library klien:
Ubah direktori ke direktori yang berisi file app.yaml API dan
class API Anda.
Jalankan alat command line Endpoints yang mirip dengan berikut ini:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)."]]