이 페이지에서는 Endpoints 프레임워크 명령줄 도구를 사용하여 Python 백엔드 API(서버에서 실행되는 코드)에서 클라이언트 라이브러리를 생성하는 방법을 설명합니다. 모든 Java 또는 Android 앱은 이 라이브러리를 사용하여 API를 호출할 수 있습니다.
개발자는 Endpoints Frameworks 명령줄 도구를 사용하여 애플리케이션이 API에 액세스할 수 있게 해주는 클라이언트 라이브러리 번들을 생성할 수 있습니다. 클라이언트 라이브러리를 생성하면 Endpoints 프레임워크 명령줄 도구는 API 노출 영역을 기술하는 검색 문서를 자동으로 생성합니다.
Endpoints 프레임워크 명령줄 도구인 endpointscfg.py는 Endpoints 프레임워크 라이브러리에서 사용할 수 있습니다. pip를 사용하여 Endpoints 프레임워크 라이브러리를 설치하는 방법에 대한 자세한 내용은 Endpoints 프레임워크 라이브러리 설치를 참조하세요.
다음 명령어를 사용하려면 lib 디렉터리에 Endpoints 프레임워크 라이브러리가 설치되어 있어야 합니다. 또한 안내에서는 백엔드 API를 이미 만들었다고 가정합니다. 샘플 코드에서 Endpoints 프레임워크 명령줄 도구를 사용하는 예시는 Python용 Endpoints Framework 가이드를 참조하세요.
API에서 클라이언트 라이브러리 번들 생성
Endpoints 프레임워크 명령줄 도구를 사용하면 다음 유형의 클라이언트 번들을 생성할 수 있습니다.
Maven: 이 번들에는 Endpoints 프레임워크 및 Google API 클라이언트 라이브러리 종속 항목을 포함하는 pom.xml 파일이 포함됩니다.
readme.html 파일은 다양한 클라이언트 애플리케이션 유형별로 pom.xml 파일에 추가해야 하는 항목과 Maven을 사용하여 API에 맞는 클라이언트 라이브러리를 빌드하는 방법에 대한 자세한 정보를 제공합니다.
Gradle: 이 번들에는 Endpoints 프레임워크 및 Google API 클라이언트 라이브러리 종속 항목을 포함하는 build.gradle 파일이 포함됩니다.
readme.html 파일은 다양한 클라이언트 애플리케이션 유형별로 build.gradle 파일에 추가해야 하는 항목과 Gradle을 사용하여 API에 맞는 클라이언트 라이브러리를 빌드하는 방법에 대한 자세한 정보를 제공합니다.
기본 클라이언트 번들: 이 번들에는 모든 종속 항목 라이브러리와 생성된 source.jar 파일이 포함됩니다. 이 파일은 클라이언트에서 API를 호출하는 데 사용하는 자바 라이브러리입니다. 이 번들은 OAuth를 포함한 모든 Google API 클라이언트 라이브러리 기능을 클라이언트에 제공합니다. readme.html 파일은 다양한 유형의 클라이언트 애플리케이션에 필요한 .jar 파일의 목록과 클라이언트 라이브러리 사용을 위한 그 밖의 자세한 정보를 제공합니다.
Android 앱에서 클라이언트 라이브러리를 사용하는 경우 Gradle 클라이언트 번들을 사용하는 것이 좋습니다.
클라이언트 라이브러리 생성
클라이언트 라이브러리를 생성하려면 다음 안내를 따르세요.
API의 app.yaml 파일과 API 서비스 클래스가 있는 디렉터리로 변경합니다. 또는 --application 옵션을 사용하여 애플리케이션 디렉터리의 다른 위치를 지정합니다.
기본적으로 이 도구는 현재 디렉터리의 백엔드 API에서 생성됩니다. 다른 디렉터리를 사용하여 생성하려면 app.yaml을 포함하는 디렉터리의 경로와 API를 구현하는 서비스 클래스를 지정합니다.
--application /my_path/my_api_dir
build-system
생성할 클라이언트 번들의 유형을 지정할 수 있습니다. Android용 Gradle 클라이언트 번들에는 gradle을 지정하고, Maven 클라이언트 번들에는 maven을 지정하고, 종속 항목 라이브러리와 소스 jar만 포함하는 번들에는 default를 지정하거나 이 옵션을 생략합니다.
--build-system=gradle -bs gradle
hostname
검색 문서의 rootURL을 지정합니다. 이 옵션은 백엔드 API 프로젝트 app.yaml([YOUR_APP_ID].appspot.com) 내부의 application 항목에서 파생된 기본값과 API의 데코레이터에 정의된 hostname을 재정의합니다. 이 옵션은 로컬 테스트를 위해 호스트 이름 localhost를 rootURL로 제공하는 등의 용도로 사용할 수 있습니다.
--hostname localhost
format
REST의 경우 기본값인 rest만 지원되기 때문에 이 옵션은 지정하지 않습니다.
필요 없습니다. 기본값을 사용합니다.
output
출력이 기록되는 디렉터리를 설정합니다. 기본값: 도구가 호출되는 디렉터리
--output /mydir -o /mydir
지원되는 클라이언트 플랫폼
Endpoints 프레임워크 명령줄 도구로 생성된 클라이언트 번들에서 지원되는 플랫폼은 다음과 같습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eThe Endpoints Frameworks command-line tool generates client library bundles, including Maven, Gradle, and default, for Java or Android apps to interact with your Python backend API.\u003c/p\u003e\n"],["\u003cp\u003eThis tool automatically creates a Discovery document detailing your API's structure when generating a client library.\u003c/p\u003e\n"],["\u003cp\u003eTo generate a client library, navigate to the directory containing your API's \u003ccode\u003eapp.yaml\u003c/code\u003e and service classes, then use the \u003ccode\u003eendpointscfg.py get_client_lib\u003c/code\u003e command with the target language, options, and API class name.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify options such as \u003ccode\u003e--application\u003c/code\u003e, \u003ccode\u003e--build-system\u003c/code\u003e, \u003ccode\u003e--hostname\u003c/code\u003e, and \u003ccode\u003e--output\u003c/code\u003e to customize the client library generation process.\u003c/p\u003e\n"],["\u003cp\u003eThe command \u003ccode\u003eendpointscfg.py get_openapi_spec\u003c/code\u003e generates an OpenAPI document from your API, and it supports options like \u003ccode\u003e--application\u003c/code\u003e, \u003ccode\u003e--hostname\u003c/code\u003e, and \u003ccode\u003e--output\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Cloud Endpoints Frameworks for App Engine command-line tool\n\nThis page describes how to use the Endpoints Frameworks command-line tool 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.\n\nYou can generate client library bundles that allow applications to access your\nAPI using the Endpoints Frameworks command-line tool. When you\ngenerate a client library, the Endpoints Frameworks command-line tool\nautomatically generates a\n[Discovery document](https://developers.google.com/discovery/v1/reference/apis)\nthat describes the surface of your API.\n\nThe Endpoints Frameworks command-line tool,`endpointscfg.py` is\navailable in the Endpoints Frameworks library. For information on\ninstalling the Endpoints Frameworks library using `pip`, see\n[Installing the Endpoints Frameworks library](/endpoints/docs/frameworks/python/get-started-frameworks-python#installing_the_endpoints_frameworks_library).\nNote that the following commands assume you have installed the\nEndpoints Frameworks library in a directory called `lib`. Additionally,\nthe instructions assume you have created your backend API. See the\n[Endpoints Frameworks for Python tutorial](/endpoints/docs/frameworks/python/get-started-frameworks-python)\nfor an example of using the Endpoints Frameworks command-line tool on\nsample code.\n\n\nGenerating a client library bundle from an API\n----------------------------------------------\n\nYou can use the Endpoints Frameworks command-line tool to generate the\nfollowing types of client bundles:\n\n- Maven: This bundle includes a `pom.xml` file with the\n Endpoints Frameworks and Google API Client Library dependencies.\n The `readme.html` file provides detailed information on what you need to add\n to your `pom.xml` file for different types of client\n applications and how to build a client library for your API using Maven.\n\n- Gradle: This bundle includes a `build.gradle` file with the\n Endpoints Frameworks and Google API Client Library dependencies.\n The `readme.html` file provides detailed information on what you need to add\n to your `build.gradle` file for different types of client applications and\n how to build a client library for your API using Gradle.\n\n- Default client bundle: This bundle contains all the dependency libraries and\n the generated `source.jar` file, which is the Java library that you use in\n your client to call your API. This bundle provides your client with all of\n the Google API Client Library capabilities, including OAuth. The\n `readme.html` file lists the `.jar` files that are required for different\n types of client applications and other details for using the client library.\n\nIf you are using the client library with an Android app, we recommend that you\nuse a Gradle client bundle.\n\n### Generating the client library\n\nTo generate the client library:\n\n1. Change directory to the directory containing your API's `app.yaml`\n file and API service classes. Alternatively, use the\n [`--application`](#options)\n option to specify some other location of your application directory.\n\n2. Invoke the Endpoints Frameworks command-line tool similar to the\n following:\n\n 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.\n3. Wait for the tool to generate the client library; on success the tool displays a\n message similar to this one:\n\n API client library written to ./echo-v1.zip\n\n4. Add the client library JAR to your Android app.\n\n5. Repeat the preceding steps every time you modify your API code.\n\nThe client library bundle is written to the current directory unless you\nspecify some other output directory using the\n[`output`](#options)\noption.\n\n### Command-line syntax\n\nThe basic syntax is as follows: \n\n```\n/path-to/your-app/lib/endpointscfg.py get_client_lib TARGET_LANG OPTIONS CLASS_NAME\n```\n\nwhere:\n\n- \u003cvar translate=\"no\"\u003eTARGET_LANG\u003c/var\u003e specifies the type of client bundle you want to create. Currently, you are required to supply the value `java` (for Java clients such as Android).\n- \u003cvar translate=\"no\"\u003eOPTIONS\u003c/var\u003e, if supplied, is one or more items shown in the [Options table](#options)\n- \u003cvar translate=\"no\"\u003eCLASS_NAME\u003c/var\u003e is the fully qualified class name of your API.\n\n| **Note:** If your API is implemented from multiple classes, specify each of them separated by a space.\n\n### Options\n\nYou can use the following options:\n\n\n### Supported client platforms\n\nThe following platforms are supported in the client bundle produced by the\nEndpoints Frameworks command-line tool:\n\n- Java 7 and higher:\n- [Android](https://github.com/googleapis/google-api-java-client/wiki/Android) 1.6 and higher.\n- [App Engine](https://github.com/googleapis/google-api-java-client/wiki).\n\nGenerating an OpenAPI document from an API\n------------------------------------------\n\nThe `endpointscfg.py` tool provides a command to generate an OpenAPI document\nfrom an API backend. The command syntax is: \n\n lib/endpoints/endpointscfg.py get_openapi_spec\n [-h]\n [-a APPLICATION]\n [--hostname HOSTNAME]\n [-o OUTPUT]\n service [service ...]\n\n positional arguments:\n service Fully qualified service class name.\n\n optional arguments:\n -h, --help Show this help message and exit.\n -a APPLICATION, --application APPLICATION\n The path to the Python App Engine application.\n --hostname HOSTNAME Default application hostname, if none is specified for the API service.\n -o OUTPUT, --output OUTPUT\n The directory to store output files.\n --x-google-api-name Add the 'x-google-api-name' field to the generated OpenAPI document.\n\nFor example, using [the `echo` example](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/endpoints-frameworks-v2/echo): \n\n $ lib/endpoints/endpointscfg.py get_openapi_spec --hostname=echo-example.appspot.com main.EchoApi\n OpenAPI spec written to ./echov1openapi.json"]]