概要
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Python クライアント ライブラリは GitHub でホストされ、パッケージは PyPI で入手できます。
要件
このライブラリには Python 3.8 以降が必要です。
前提条件
ライブラリをインストールする前に、デベロッパー トークンとクライアント顧客 ID が必要になります。取得方法については、前提条件のセクションをご覧ください。他の必要な OAuth2 トークンは、後の手順で生成します。
ランタイムと依存関係の互換性
Python クライアント ライブラリは、Python Software Foundation が公開しているサポートされているバージョンの Python ランタイムとの互換性を維持します。ただし、ステータスが「feature」または「prerelease」のバージョンは除きます。
新しいバージョンの Python ランタイムを採用する際は、リリース後の四半期末までに、最新のランタイムと互換性のある新しいバージョンの Python クライアント ライブラリをリリースすることを目指しています。たとえば、10 月に新しいランタイムがリリースされた場合、互換性のあるバージョンの Python クライアント ライブラリは、翌年の 3 月末までに利用可能になります。
サポート終了(EOL)に達した Python ランタイムは、python.org のサポートされていないバージョン セクションに記載されているサポート終了日を過ぎるとサポートされません。
EOL に達した後は、サポートされていない Python ランタイムと互換性のないバージョンの Python クライアント ライブラリをいつでもリリースする可能性があります。
依存関係(特に、Python クライアント ライブラリで必須としてリストされている Google が管理するパッケージ)については、Google が管理し、Google の OSS 破壊的変更ポリシーに従って「サポート対象」と見なされるパッケージとの互換性を維持します。
サポートされている Python ランタイムと依存関係の完全なリストについては、依存関係のページをご覧ください。
インストール
インストールのドキュメントの手順に沿って、PyPi からライブラリをインストールし、このページに戻ります。
構成
ライブラリをインストールしたら、ライブラリの構成を設定する必要があります。ライブラリを構成する方法は複数あり、構成に関するドキュメントで説明しています。
認証
構成タイプを選択したら、API にリクエストを行うために必要な残りの OAuth2 トークンを生成します。サポートされている OAuth2 フローは複数あり、以下のリストに記載されています。フローの違いと、アプリケーションに最適なフローの選択については、OAuth のドキュメントをご覧ください。
API リクエストの作成
OAuth2 トークンを構成に組み込んだら、API リクエストを行う準備が整います。ライブラリが API リクエストを行うように正しく構成されていることをテストする簡単な方法については、キャンペーンの取得の例をご覧ください。
get_campaigns.py
サンプルを実行するには、ローカルにインストールした googleads-python
クライアント ライブラリのルート ディレクトリで、次のコマンドを実行します。
$ python examples/basic_operations/get_campaigns.py -c \
INSERT_YOUR_CUSTOMER_ID_HERE
参考情報
API リクエストを行えるようになったら、クライアント ライブラリの次の使用に進みます。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-26 UTC。
[null,null,["最終更新日 2025-08-26 UTC。"],[[["\u003cp\u003eThe Google Ads Python client library requires Python 3.8 or later and is compatible with supported Python runtimes, with new runtime support added by the end of the quarter following a new runtime's release.\u003c/p\u003e\n"],["\u003cp\u003eYou need a developer token and client customer ID before installation, and OAuth2 tokens are generated during the authentication process.\u003c/p\u003e\n"],["\u003cp\u003eConfiguration options are provided, along with guidance on OAuth flows for desktop/web and service accounts to authenticate API requests.\u003c/p\u003e\n"],["\u003cp\u003eA sample \u003ccode\u003eget_campaigns.py\u003c/code\u003e script helps test API request functionality, and resources on logging, field masks, and other library features are available.\u003c/p\u003e\n"],["\u003cp\u003eThe library is hosted on GitHub and available on PyPI for installation.\u003c/p\u003e\n"]]],[],null,["# Overview\n\nThe Python client library is hosted [on GitHub](https://github.com/googleads/google-ads-python),\nand the package is available on [PyPI](//pypi.org/project/google-ads/).\n\n### Requirements\n\nThe library requires Python 3.8 or later.\n\n### Prerequisites\n\nBefore installing the library, you will need a developer token and\nclient customer ID. Instructions on how to obtain them are outlined in the\n[prerequisites](/google-ads/api/docs/get-started/introduction) section.\nNote that you will generate the other required OAuth2 tokens in later steps.\n\n### Runtime and dependency compatibility\n\nThe Python client library maintains compatibility with the Python runtimes in\nthe\n[Supported Versions](https://devguide.python.org/versions/#supported-versions)\nsection published by the\n[Python Software Foundation](https://www.python.org/psf-landing/), except for\nversions with a status of \"feature\" or \"prerelease\".\n\nWhen adopting new versions of the Python runtime, we aim to release a new\nversion of the Python client library that is compatible with the latest runtime\nby the end of the quarter following its release. For example, if a new runtime\nis released in October, a compatible version of the Python client library will\nbe available by the end of March in the following year.\n\nPython runtimes that have reached End of Life (EOL) are not supported past the\nEnd of Life date in the\n[Unsupported Versions](https://www.python.org/psf-landing/) section of\n[python.org](https://www.python.org/).\n\nWe may release a version of the Python client library that is incompatible with\nunsupported Python runtimes at any point after they reach EOL.\n\nFor dependencies, (specifically, any Google-maintained packages that are\n[listed as required](//github.com/googleads/google-ads-python/blob/ef62b42152781ee6dc9081222dca49a758760544/setup.py#L18)\nby the Python client library), we will maintain compatibility with packages that\nare Google-maintained, and considered \"supported\" according to Google's\n[OSS Breaking Change Policy](https://opensource.google/documentation/policies/library-breaking-change).\n\nFor a complete list of supported Python runtimes and dependencies, see the\n[Dependencies](/google-ads/api/docs/client-libs/python/dependencies) page.\n\n### Installation\n\nFollow the instructions in our [installation](/google-ads/api/docs/client-libs/python/installation#install_the_module_from_pypi)\ndocumentation to install the library from PyPi and return to this page.\n\n### Configuration\n\nOnce you have installed the library you will need to set up a configuration for\nit. There are multiple ways to configure the library, which are described in our\n[configuration](/google-ads/api/docs/client-libs/python/configuration) documentation.\n\n### Authentication\n\nOnce you've chosen a configuration type you can proceed with generating the\nremaining OAuth2 tokens needed to make requests to the API. There are multiple\nsupported OAuth2 flows, which are documented in the list below. For details on\nthe differences between the flows and help deciding which is best for your\napplication, see our [OAuth](/google-ads/api/docs/oauth/overview) documentation.\n\n- [OAuth desktop and web application flows](/google-ads/api/docs/client-libs/python/oauth-web)\n- [OAuth service account flow](/google-ads/api/docs/client-libs/python/oauth-service)\n\n### Making an API request\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nOnce you've incorporated your OAuth2 tokens into your configuration, you're\nready to make an API request. Refer to the\n[get campaigns](/google-ads/api/samples/get-campaigns#python) example for\na simple way to test that the library is properly configured to make API\nrequests.\n\nTo run the `get_campaigns.py` sample, in the root directory of your locally\ninstalled `googleads-python` client library, run the following command: \n\n $ python examples/basic_operations/get_campaigns.py -c \\\n INSERT_YOUR_CUSTOMER_ID_HERE\n\n### Additional resources\n\nAfter you're able to make an API request, proceed to these uses of the client\nlibrary:\n\n- [Logging](/google-ads/api/docs/client-libs/python/logging)\n- [Field Masks](/google-ads/api/docs/client-libs/python/field-masks)\n- [Resource Names](/google-ads/api/docs/client-libs/python/resource-names)\n- [Proto Getters](/google-ads/api/docs/client-libs/python/proto-getters)\n- [Setting Empty Message Fields](/google-ads/api/docs/client-libs/python/empty-message-fields)"]]