با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
کتابخانه کلاینت پایتون در GitHub میزبانی می شود و بسته در PyPI در دسترس است.
الزامات
کتابخانه به پایتون 3.8 یا بالاتر نیاز دارد.
پیش نیازها
قبل از نصب کتابخانه، به یک رمز توسعه دهنده و شناسه مشتری مشتری نیاز دارید. دستورالعمل نحوه به دست آوردن آنها در بخش پیش نیازها ذکر شده است. توجه داشته باشید که سایر توکن های مورد نیاز OAuth2 را در مراحل بعدی تولید خواهید کرد.
سازگاری زمان اجرا و وابستگی
کتابخانه کلاینت پایتون سازگاری با زمانهای اجرا پایتون در بخش نسخههای پشتیبانی شده منتشر شده توسط بنیاد نرمافزار پایتون را حفظ میکند، به جز نسخههایی که وضعیت «ویژگی» یا «پیشنشر» دارند.
هنگام پذیرش نسخههای جدید زمان اجرا پایتون، قصد داریم نسخه جدیدی از کتابخانه کلاینت پایتون را منتشر کنیم که با آخرین زمان اجرا تا پایان سهماهه پس از انتشار آن سازگار باشد. به عنوان مثال، اگر زمان اجرا جدیدی در ماه اکتبر منتشر شود، نسخه سازگار کتابخانه کلاینت پایتون تا پایان ماه مارس سال بعد در دسترس خواهد بود.
زمانهای اجرا پایتون که به پایان عمر (EOL) رسیدهاند، پس از تاریخ پایان عمر در بخش نسخههای پشتیبانینشده در python.org پشتیبانی نمیشوند.
ممکن است نسخه ای از کتابخانه کلاینت پایتون را منتشر کنیم که با زمان اجراهای پشتیبانی نشده پایتون در هر زمانی پس از رسیدن به EOL ناسازگار باشد.
برای وابستگی ها، (به طور خاص، هر بسته نگهداری شده توسط Google که طبق نیاز کتابخانه مشتری Python فهرست شده است)، ما سازگاری با بسته هایی را حفظ خواهیم کرد که توسط Google نگهداری می شوند و طبق خط مشی تغییر OSS Google "پشتیبانی می شوند".
برای لیست کاملی از زمان های اجرا و وابستگی های پشتیبانی شده پایتون، به صفحه Dependencies مراجعه کنید.
نصب و راه اندازی
دستورالعمل های موجود در اسناد نصب ما را دنبال کنید تا کتابخانه را از PyPi نصب کنید و به این صفحه بازگردید.
پیکربندی
هنگامی که کتابخانه را نصب کردید، باید یک پیکربندی برای آن تنظیم کنید. راه های مختلفی برای پیکربندی کتابخانه وجود دارد که در اسناد پیکربندی ما توضیح داده شده است.
احراز هویت
هنگامی که یک نوع پیکربندی را انتخاب کردید، میتوانید با تولید توکنهای OAuth2 باقیمانده مورد نیاز برای درخواست به API ادامه دهید. چندین جریان OAuth2 پشتیبانی شده وجود دارد که در لیست زیر مستند شده است. برای جزئیات بیشتر در مورد تفاوتهای بین جریانها و کمک به تصمیمگیری بهترین گزینه برای برنامه شما، به مستندات OAuth ما مراجعه کنید.
هنگامی که توکن های OAuth2 خود را در پیکربندی خود قرار دادید، آماده درخواست API هستید. به مثال دریافت کمپینها مراجعه کنید تا روشی ساده برای آزمایش اینکه آیا کتابخانه بهدرستی برای درخواستهای API پیکربندی شده است.
برای اجرای نمونه get_campaigns.py ، در دایرکتوری ریشه کتابخانه مشتری googleads-python که به صورت محلی نصب شده است، دستور زیر را اجرا کنید:
تاریخ آخرین بهروزرسانی 2025-09-03 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-09-03 بهوقت ساعت هماهنگ جهانی."],[[["\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)"]]