সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
Google API ক্লায়েন্ট (যেমন পাইথন)
এখানে কিছু নমুনা রয়েছে যা Google API ক্লায়েন্ট লাইব্রেরি ব্যবহার করে। এই উদাহরণগুলি পাইথনে লেখা হয়, তবে সেগুলি অন্যান্য প্রোগ্রামিং ল্যাঙ্গুয়েজ যেমন পিএইচপি-তে একই রকম হতে পারে।
Google API ক্লায়েন্ট ব্যবহার করার জন্য, আপনার একটি API কী এবং একটি পরিষেবা অ্যাকাউন্ট নথি উভয়েরই প্রয়োজন হবে, যেমন Quickstart-এর অনুমতি বিভাগে বর্ণিত হয়েছে
requirements.txt:
google-api-python-client>=2.98.0
insert.py:
from googleapiclient.discovery import build
from google.oauth2 import service_account
# This must be a valid service json document
SERVICE_ACCOUNT_FILE="/.../google.....json"
SCOPES=["https://www.googleapis.com/auth/content"]
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
url="https://css.googleapis.com/$discovery/rest?version=v1"
# This must be a valid API key
key="..."
with build(serviceName= 'css', version= 'v1', discoveryServiceUrl=url,
developerKey=key,
credentials=credentials) as service:
# Add more parameters
# Use your CSS domain ID
request = service.accounts().cssProductInputs().insert(parent="accounts/1234567")
response = request.execute()
print(f"{response}")
list.py:
# Code from above
with build(serviceName= 'css', version= 'v1', discoveryServiceUrl=url,
developerKey=key,
credentials=credentials) as service:
# Use your CSS domain ID
request = service.accounts().cssProducts().list(parent="accounts/1234567")
response = request.execute()
print(f"---\nResponse: {response}")
# Use your CSS domain ID
# the id is built using your country/language (it in this example) and the
# id you gave when uploading the item.
request = service.accounts().cssProducts().get(name="accounts/1234567/cssProducts/it~IT~myproductid")
response = request.execute()
print(f"---\nResponse: {response}")
```language=python
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThis documentation provides Python examples of using the Google API Client library for interactions with Google services.\u003c/p\u003e\n"],["\u003cp\u003eUsers need an API key and a service account document for authentication, as detailed in the linked quickstart guide.\u003c/p\u003e\n"],["\u003cp\u003eCode snippets illustrate how to build a service object using credentials and an API key to perform actions like inserting and listing data with Google services.\u003c/p\u003e\n"],["\u003cp\u003eThe provided \u003ccode\u003einsert.py\u003c/code\u003e and \u003ccode\u003elist.py\u003c/code\u003e examples demonstrate creating, executing, and printing responses from Google API requests.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples may be adapted for other programming languages with similar concepts, as noted with the PHP example.\u003c/p\u003e\n"]]],[],null,["Google API Client (e.g. Python)\n-------------------------------\n\nHere are some samples which use the Google API client library. These examples\nare written in python, but they may be similar in other programming languages,\nsuch as PHP.\n\nFor using the Google API clients, you will need both an\n[API key](https://cloud.google.com/docs/authentication/api-keys) and a service\naccount document, as described in the [Permissions section in\nquickstart](/comparison-shopping-services/api/guides/quickstart)\n\nrequirements.txt:\n\n`google-api-python-client\u003e=2.98.0`\n\ninsert.py: \n\n from googleapiclient.discovery import build\n from google.oauth2 import service_account\n\n # This must be a valid service json document\n SERVICE_ACCOUNT_FILE=\"/.../google.....json\"\n SCOPES=[\"https://www.googleapis.com/auth/content\"]\n\n credentials = service_account.Credentials.from_service_account_file(\n SERVICE_ACCOUNT_FILE, scopes=SCOPES)\n\n url=\"https://css.googleapis.com/$discovery/rest?version=v1\"\n # This must be a valid API key\n key=\"...\"\n\n with build(serviceName= 'css', version= 'v1', discoveryServiceUrl=url,\n developerKey=key,\n credentials=credentials) as service:\n # Add more parameters\n # Use your CSS domain ID\n request = service.accounts().cssProductInputs().insert(parent=\"accounts/1234567\")\n response = request.execute()\n print(f\"{response}\")\n\nlist.py: \n\n # Code from above\n with build(serviceName= 'css', version= 'v1', discoveryServiceUrl=url,\n developerKey=key,\n credentials=credentials) as service:\n # Use your CSS domain ID\n request = service.accounts().cssProducts().list(parent=\"accounts/1234567\")\n response = request.execute()\n print(f\"---\\nResponse: {response}\")\n\n # Use your CSS domain ID\n # the id is built using your country/language (it in this example) and the\n # id you gave when uploading the item.\n request = service.accounts().cssProducts().get(name=\"accounts/1234567/cssProducts/it~IT~myproductid\")\n response = request.execute()\n print(f\"---\\nResponse: {response}\")\n ```language=python"]]