پیش نیازها
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این سند کارهایی را که باید قبل از نوشتن اولین درخواست مشتری خود انجام دهید، شرح می دهد.
یک حساب Google دریافت کنید
برای استفاده از این API به یک حساب Google نیاز دارید. حساب شما باید مجوز کنسول جستجوی مناسب را در یک ویژگی خاص داشته باشد تا بتوان آن متد را در آن ویژگی فراخوانی کرد. به عنوان مثال، برای اجرای searchAnalytics.query به مجوز خواندن در آن ویژگی نیاز دارید.
کنسول جستجوی گوگل را امتحان کنید
این مستندات API فرض میکند که از کنسول جستجوی Google استفاده کردهاید، و با مفاهیم برنامهنویسی وب و قالبهای دادههای وب آشنا هستید.
اگر از کنسول جستجوی گوگل استفاده نکرده اید، قبل از شروع به کدنویسی، رابط کاربری را امتحان کنید. هر API عملکرد یک گزارش را در کنسول جستجو نشان می دهد. برای درک اطلاعاتی که دریافت می کنید، باید قبل از استفاده از یک API ، اسناد مربوط به گزارش معادل را بخوانید .
یک پروژه و اعتبار برای مشتری خود ایجاد کنید
قبل از اینکه بتوانید درخواستها را به کنسول جستجوی Google ارسال کنید، باید به Google در مورد مشتری خود بگویید و دسترسی به API را فعال کنید. این کار را با استفاده از Google API Console برای ایجاد یک پروژه ، که مجموعه ای نامگذاری شده از تنظیمات و اطلاعات دسترسی API است، انجام می دهید و برنامه خود را ثبت می کنید.
همه APIهای کنسول جستجو به جز Testing Tools API به اعتبارنامه OAuth2 نیاز دارند. راهنمای شروع سریع پایتون و جاوا جزئیاتی را در مورد نحوه ایجاد یک پروژه و دریافت اعتبار برای مشتری شما ارائه می دهد.
اصول REST را درک کنید
دو راه برای فراخوانی API وجود دارد:
اگر تصمیم دارید از کتابخانه های مشتری استفاده نکنید، باید اصول REST را بدانید.
REST اصول اولیه
REST سبکی از معماری نرم افزار است که یک رویکرد راحت و سازگار برای درخواست و اصلاح داده ها ارائه می دهد.
اصطلاح REST مخفف " انتقال دولت نمایندگی " است. در زمینه Google API ها، به استفاده از افعال HTTP برای بازیابی و اصلاح نمایش داده های ذخیره شده توسط Google اشاره دارد.
در یک سیستم RESTful، منابع در یک فروشگاه داده ذخیره می شوند. یک سرویس گیرنده درخواستی را ارسال می کند که سرور یک عمل خاص را انجام دهد (مانند ایجاد، بازیابی، به روز رسانی یا حذف یک منبع)، و سرور این عمل را انجام می دهد و پاسخی را می فرستد، اغلب به شکل یک نمایش از منبع مشخص شده.
در API های RESTful Google، مشتری با استفاده از یک فعل HTTP مانند POST
، GET
، PUT
، یا DELETE
، اقدامی را مشخص می کند. این یک منبع را توسط یک URI منحصر به فرد جهانی به شکل زیر مشخص می کند:
https://www.googleapis.com/apiName/apiVersion/resourcePath?parameters
از آنجایی که همه منابع API دارای URI های منحصر به فرد قابل دسترسی با HTTP هستند، REST ذخیره داده را فعال می کند و برای کار با زیرساخت های توزیع شده وب بهینه شده است.
ممکن است تعاریف روش را در مستندات استانداردهای HTTP 1.1 مفید بیابید. آنها شامل مشخصات GET
، POST
، PUT
و DELETE
هستند.
REST در Google Search Console API
عملیات API کنسول جستجوی Google مستقیماً به افعال REST HTTP نگاشت میشود.
فرمت اکثر URI های API کنسول جستجوی گوگل چیزی شبیه به این است:
VERB https://www.googleapis.com/webmasters/v3/resourcePath?parameters
مجموعه کامل URIها و افعال استفاده شده برای هر روش در نمای کلی مرجع API کنسول جستجوی Google آورده شده است.
اصول JSON را درک کنید
Google Search Console API دادهها را در قالب JSON برمیگرداند.
JSON (JavaScript Object Notation) یک قالب داده رایج و مستقل از زبان است که نمایش متنی ساده ای از ساختارهای داده دلخواه را ارائه می دهد. برای اطلاعات بیشتر، به json.org مراجعه کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2024-07-23 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-07-23 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eBefore using the Google Search Console API, you must have a Google Account with the necessary Search Console permissions.\u003c/p\u003e\n"],["\u003cp\u003eFamiliarize yourself with the Google Search Console user interface and its reports to understand the data the API provides.\u003c/p\u003e\n"],["\u003cp\u003eCreate a project in the Google API Console and obtain OAuth2 credentials to enable your client application's access to the API.\u003c/p\u003e\n"],["\u003cp\u003eUnderstand REST principles, particularly HTTP verbs and resource URIs, to interact with the API directly or choose to use client libraries.\u003c/p\u003e\n"],["\u003cp\u003eThe Google Search Console API uses JSON for data exchange, so understanding this format is essential for processing API responses.\u003c/p\u003e\n"]]],["Before creating a client application, obtain a Google Account with Search Console permissions. Familiarize yourself with Google Search Console's user interface and relevant report documentation. Create a Google API Console project to register your application and get OAuth2 credentials. If not using client libraries, understand REST basics, including HTTP verbs (GET, POST, PUT, DELETE) and URIs. Finally, learn JSON, the data format used by the Google Search Console API.\n"],null,["# Prerequisites\n\nThis document describes the things you should do before\nwriting your first client application.\n\nGet a Google Account\n--------------------\n\nYou need a [Google Account](https://www.google.com/accounts/NewAccount) to use this API.\nYour account must have the appropriate Search Console permission on a given property in order to\ncall that method on that property. For example, in order to run [searchAnalytics.query](/webmaster-tools/v1/searchanalytics/query)\nyou need read permissions on that property.\n\nTry out Google Search Console\n-----------------------------\n\nThis API documentation assumes that you've used [Google Search Console](https://search.google.com/search-console/), and that you're familiar with web programming concepts and web data formats.\n\nIf you haven't used Google Search Console, then try out the [user interface](https://search.google.com/search-console/) before starting to code.\nEach API represents the functionality of a report in Search Console. You should [read the documentation for the equivalent report](https://support.google.com/webmasters/topic/9456557) before using an API in order to understand the data you receive.\n\nCreate a project and credentials for your client\n------------------------------------------------\n\nBefore you can send requests to Google Search Console, you need to tell Google about your client and\nactivate access to the API. You do this by using the Google API Console to create a project,\nwhich is a named collection of settings and API access information, and register your application.\n\n\nAll Search Console APIs except the Testing Tools API require OAuth2 credentials.\nThe Python and Java quickstart guides provide details on how to create a project and get credentials for your client.\n\nUnderstand REST basics\n----------------------\n\nThere are two ways to invoke the API:\n\n- Sending HTTP requests and parsing the responses.\n- Using [client libraries](./libraries).\n\nIf you decide not to use client libraries, you'll need to understand the basics of REST.\n\n#### REST basics\n\nREST is a style of software architecture that provides a convenient and consistent approach to requesting and modifying data.\n\nThe term REST is short for \"[Representational State Transfer](https://en.wikipedia.org/wiki/Representational_state_transfer).\" In the context of Google APIs, it refers to using HTTP verbs to retrieve and modify representations of data stored by Google.\n\nIn a RESTful system, resources are stored in a data store; a client sends a request that the server perform a particular action (such as creating, retrieving, updating, or deleting a resource), and the server performs the action and sends a response, often in the form of a representation of the specified resource.\n\nIn Google's RESTful APIs, the client specifies an action using an HTTP verb such as `POST`, `GET`, `PUT`, or `DELETE`. It specifies a resource by a globally-unique URI of the following form: \n\n```\nhttps://www.googleapis.com/apiName/apiVersion/resourcePath?parameters\n```\n\nBecause all API resources have unique HTTP-accessible URIs, REST enables data caching and is optimized to work with the web's distributed infrastructure.\n\nYou may find the [method definitions](https://tools.ietf.org/html/rfc7231#section-4.3) in the HTTP 1.1 standards documentation useful; they include specifications for `GET`, `POST`, `PUT`, and `DELETE`.\n\n### REST in the Google Search Console API\n\nThe Google Search Console API operations map directly to REST HTTP verbs.\n\nThe format for most Google Search Console API URIs are something like this: \n\n```\nVERB https://www.googleapis.com/webmasters/v3/resourcePath?parameters\n```\n\nThe full set of URIs and verbs used for each method are given in the [Google Search Console API Reference](/webmaster-tools/v1/api_reference_index) overview.\n\nUnderstand JSON basics\n----------------------\n\nThe Google Search Console API returns data in JSON format.\n\n\n[JSON](http://en.wikipedia.org/wiki/JSON) (JavaScript Object Notation) is a common, language-independent data format that provides a simple text representation of arbitrary data structures. For more information, see [json.org](http://www.json.org/).\n\n\u003cbr /\u003e"]]