المتطلبات الأساسية
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يصف هذا المستند الأشياء التي يجب عليك القيام بها قبل
كتابة تطبيق العميل الأول.
الحصول على حساب Google
تحتاج إلى حساب Google لاستخدام واجهة برمجة التطبيقات هذه.
يجب أن يكون لدى حسابك إذن Search Console المناسب على موقع إلكتروني معيّن حتى تتمكّن من
طلب استخدام هذه الطريقة على ذلك الموقع. على سبيل المثال، لتنفيذ searchAnalytics.query، تحتاج إلى أذونات قراءة على ذلك الموقع.
تجربة Google Search Console
تفترض مستندات واجهة برمجة التطبيقات هذه أنّك استخدمت Google Search Console وأنّك على دراية بمفاهيم برمجة الويب وتنسيقات بيانات الويب.
إذا لم يسبق لك استخدام Google Search Console، ننصحك بتجربة واجهة المستخدم قبل بدء الترميز.
تمثّل كل واجهة برمجة تطبيقات وظيفة تقرير في Search Console. لفهم البيانات التي تتلقّاها، يجب
قراءة المستندات الخاصة بالتقرير المكافئ قبل استخدام واجهة برمجة التطبيقات.
إنشاء مشروع وبيانات اعتماد لعميلك
قبل أن تتمكّن من إرسال طلبات إلى Google Search Console، عليك إعلام Google بعميلك وتفعيل إمكانية الوصول إلى واجهة برمجة التطبيقات. ويمكنك إجراء ذلك باستخدام وحدة التحكم في واجهة Google API لإنشاء مشروع، وهو مجموعة معرَّفة من الإعدادات ومعلومات الوصول إلى واجهة برمجة التطبيقات، ولتسجيل تطبيقك.
تتطلب جميع واجهات برمجة تطبيقات Search Console بيانات اعتماد OAuth2، باستثناء واجهة برمجة التطبيقات الخاصة بـ "أدوات الاختبار".
توفر أدلة البدء السريع للغة Python وJava تفاصيل حول كيفية إنشاء مشروع والحصول على بيانات الاعتماد لعميلك.
فهم أساسيات REST
هناك طريقتان لاستدعاء واجهة برمجة التطبيقات:
إذا قررت عدم استخدام مكتبات العملاء، فستحتاج إلى فهم أساسيات REST.
أساسيات REST
REST هو نمط من بنية البرامج التي توفر نهجًا مناسبًا ومتسقًا لطلب البيانات وتعديلها.
إنّ المصطلح REST هو اختصار لـ "التحويل التمثيلي للولاية". في سياق Google APIs، يشير ذلك إلى استخدام أفعال HTTP لاسترداد وتعديل تمثيلات البيانات التي خزنتها Google.
في نظام REST، يتم تخزين الموارد في مخزن بيانات؛ يرسل العميل طلبًا بأن يقوم الخادم بتنفيذ إجراء معين (مثل إنشاء مورد أو استرداده أو تحديثه أو حذفه)، وينفذ الخادم الإجراء ويرسل استجابة غالبًا في شكل تمثيل للمورد المحدد.
في واجهات برمجة التطبيقات RESTful من Google، يحدّد العميل إجراءً باستخدام فعل HTTP مثل POST
أو GET
أو PUT
أو DELETE
. يحدد موردًا من خلال معرف موارد منتظم (URI) فريد عالميًا بالصيغة التالية:
https://www.googleapis.com/apiName/apiVersion/resourcePath?parameters
ونظرًا لأن جميع موارد واجهة برمجة التطبيقات تتضمن معرفات موارد منتظمة (URI) فريدة يمكن الوصول إليها عبر HTTP، فإن REST تتيح التخزين المؤقت للبيانات ويتم تحسينها للعمل مع البنية الأساسية الموزَّعة على الويب.
قد تجد تعريفات الطريقة في مستندات معايير HTTP 1.1 مفيدة، وتضم مواصفات GET
وPOST
وPUT
وDELETE
.
بروتوكول REST في واجهة برمجة التطبيقات في Google Search Console
ترتبط عمليات واجهة برمجة التطبيقات في Google Search Console مباشرةً بأفعال REST HTTP.
يظهر تنسيق معظم معرّفات الموارد المنتظمة (URI) لواجهة برمجة التطبيقات الخاصة بخدمة Google Search Console على النحو التالي:
VERB https://www.googleapis.com/webmasters/v3/resourcePath?parameters
يمكنك الاطّلاع على المجموعة الكاملة من معرّفات الموارد المنتظمة (URI) والأفعال المُستخدَمة لكل طريقة في النظرة العامة على مرجع واجهة برمجة التطبيقات في Google Search Console.
فهم أساسيات JSON
تعرض واجهة برمجة التطبيقات لخدمة Google Search Console البيانات بتنسيق JSON.
JSON (JavaScript Object Notation) هو تنسيق بيانات شائع ومستقل عن اللغة ويقدم تمثيلاً نصيًا بسيطًا بُنى البيانات العشوائية. لمزيد من المعلومات، راجع json.org.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة 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"]]