تنظيم صفحاتك في مجموعات يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
هذا الدليل مخصّص للمطوّرين الذين يريدون استخدام واجهة برمجة تطبيقات AdMob للحصول على البيانات آليًا في حساباتهم على AdMob.
يجب منح الإذن لجميع طلبات بيانات من Google AdMob API من خلال OAuth2 حتى يتمكّن تطبيقك من التفاعل مع خدمات الويب نيابةً عن المستخدم. يتيح بروتوكول OAuth2 لتطبيق عميل AdMob API الوصول إلى حساب مستخدم على AdMob بدون الحاجة إلى معالجة أو تخزين اسم المستخدم أو كلمة المرور. للحصول على نظرة عامة حول التفويض، يُرجى الاطّلاع على التفويض.
اتّبِع الخطوات التالية لإنشاء بيانات اعتماد OAuth2 وإرسال طلبك الأول.
راجِع الجدول أدناه لمعرفة نوع المصادقة الأنسب لتطبيقك:
اختيار نوع مصادقة OAuth2
إذا كان ...
تطبيق الكمبيوتر
تتم إدارة جميع حساباتك على AdMob API باستخدام حساب إداري واحد على أعلى مستوى.
إذا كنت مستخدمًا جديدًا أو أردت البدء بسرعة باستخدام أبسط عملية إعداد
يصادق تطبيقك على مستخدمي Google AdMob من جهاز واحد فقط.
تطبيق الويب
عليك إثبات هويتك كمستخدم يمكنه منح تطبيقك الإذن بالوصول إلى بيانات حساب واجهة برمجة تطبيقات AdMob.
إذا أردت إنشاء بيانات اعتماد تفويض متعددة بسهولة، لإدارة حسابات تابعة لجهات خارجية مثلاً.
يتطلّب تطبيقك عناوين URL لرد الاتصال، وهي غير متاحة في مسار تطبيق سطح المكتب.
إنشاء مشروع
لبدء استخدام AdMob API، عليك أولاً إنشاء مشروع أو اختيار مشروع في Google API Console وتفعيل واجهة برمجة التطبيقات باستخدام أداة الإعداد، التي تقدّم لك إرشادات خلال العملية وتُفعِّل واجهة برمجة تطبيقات AdMob تلقائيًا.
تفعيل واجهة برمجة التطبيقات لمشروع حالي
تنطبق الخطوات التالية على المستخدمين الذين لديهم مشروع حالي ويفضّلون تفعيل واجهة برمجة التطبيقات AdMob API له يدويًا.
If prompted, select a project, or create a new one. تعرض API Library القائمة جميع واجهات برمجة التطبيقات المتاحة، ويتم تجميعها حسب فئة المنتج ومدى رواجها.
إذا لم يكن واجهة برمجة التطبيقات التي تريد تفعيلها ظاهرة في القائمة، استخدِم البحث للعثور عليها، أو انقر على عرض الكل في مجموعة المنتجات التي تنتمي إليها.
اختَر واجهة برمجة التطبيقات التي تريد تفعيلها، ثم انقر على الزر تفعيل.
If prompted, enable billing.
If prompted, read and accept the API's Terms of Service.
إنشاء بيانات اعتماد OAuth2
ترشدك التعليمات التالية خلال عملية إنشاء معرّف عميل OAuth 2.0 لاستخدامه مع مسار التطبيق المثبَّت.
إذا لم يسبق لك ضبط شاشة موافقة OAuth لهذا المشروع، سيتم توجيهك إلى ضبطها الآن. انقر على إعداد شاشة الموافقة. هناك عدة طرق لإعداد شاشة الموافقة لاستخدام معرّف عميل OAuth 2.0.
اضبط نوع المستخدم على خارجي وحالة النشر على تم النشر.
يمكنك أيضًا ضبط نوع المستخدم على خارجي وحالة النشر على اختبار، ثم إضافة مستخدمين اختباريين من خلال النقر على إضافة مستخدمين لمنحهم إذن الوصول إلى معرّف العميل لبروتوكول OAuth 2.0.
اختَر تطبيق سطح المكتب أو تطبيق الويب كنوع التطبيق، وأدخِل اسمًا له، ثم انقر على إنشاء.
عند الانتهاء، سيظهر لك معرّف عميل وسر عميل لبروتوكول OAuth 2.0، ويمكنك تنزيلهما بتنسيق JSON وحفظهما لاستخدامهما لاحقًا.
تقديم طلب
تم إنشاء واجهة برمجة التطبيقات AdMob API استنادًا إلى HTTP وJSON، ما يتيح لأي عميل HTTP عادي إرسال طلبات إلى الواجهة وتحليل استجاباتها. في المقابل، توفّر مكتبات عملاء واجهة Google API نتائج أفضل على مستوى التكامل اللغوي والأمان المعزَّز، كما تتيح إمكانية إجراء الطلبات التي تحتاج إلى إذن من المستخدم. تتوفر مكتبات البرامج بعدّة لغات برمجة، ويغنيك استخدامها عن إعداد طلبات HTTP وتحليل الاستجابات يدويًا.
بعد إنشاء بيانات اعتماد OAuth 2.0، يمكنك البدء في استخدام AdMob API. لطلب الوصول باستخدام بروتوكول OAuth 2.0، يحتاج تطبيقك أيضًا إلى معلومات النطاق:
النطاق
المعنى
https://www.googleapis.com/auth/admob.readonly
الاطّلاع على جميع بيانات AdMob وقد يشمل ذلك معلومات الحساب وإعدادات المستودع والتوسّط والتقارير والبيانات الأخرى. ولا يتضمّن ذلك البيانات الحسّاسة، مثل الدفعات أو تفاصيل الحملة.
https://www.googleapis.com/auth/admob.report
الاطّلاع على تقارير أداء الإعلانات والأرباح الاطّلاع على الرقم التعريفي للناشر والمنطقة الزمنية ورمز العملة التلقائي
أرسِل طلبك الأول لإنشاء تقرير باستخدام الأمثلة في Java أو PHP أو Python أو curl.
تاريخ التعديل الأخير: 2025-08-21 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-08-21 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThis guide helps developers programmatically access AdMob account data using the AdMob API, requiring OAuth2 authorization for secure interactions.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting, ensure you have a Google Account, an AdMob account, and familiarity with REST basics and OAuth 2.0 authorization.\u003c/p\u003e\n"],["\u003cp\u003eChoose the appropriate authentication type (Desktop or Web app) based on your app's needs and authorization process.\u003c/p\u003e\n"],["\u003cp\u003eCreate or select a Google API project and enable the AdMob API to get started, then generate OAuth2 credentials for authorization.\u003c/p\u003e\n"],["\u003cp\u003eMake your first API request using provided code examples (Java, PHP, Python, or curl) and manage token revocation for security.\u003c/p\u003e\n"]]],["To use the AdMob API, developers must authorize requests via OAuth2. Key actions include creating a project in the Google API Console and enabling the AdMob API. Developers then generate OAuth2 credentials, choosing between desktop or web app authentication types. The OAuth consent screen must be configured. Finally, with created credentials and specifying the scope (`admob.readonly` or `admob.report`), developers can use HTTP or Google API client libraries to make their first API request and start retrieving AdMob data. Shared tokens can be revoked.\n"],null,["| **Important:** New user roles and permissions will affect data returned by the AdMob API. [Learn more](//support.google.com/admob/answer/2784628)\n\nThis guide is for developers who want to use the AdMob API to\nprogrammatically get\ndata in their AdMob account.\n\nAll Google AdMob API calls must be authorized through\n[OAuth2](/identity/protocols/oauth2) so your app can interact with web services\non the user's behalf. OAuth2 enables your AdMob API client app to access a\nuser's AdMob account without having to handle or store the user's username or\npassword. For an overview of authorization, see\n[Authorization](/admob/api/v1/how-tos/authorizing).\n\nPerform the following steps to generate the OAuth2 credentials and make your\nfirst request.\n\nPrerequisites\n\n- A [Google Account](//google.com/accounts/NewAccount).\n\n- A [Google AdMob account](//admob.google.com/home/get-started).\n\n- Familiarity with [REST basics](/admob/api/v1/prereqs#rest) and [authorizing requests with\n OAuth 2.0](/admob/api/v1/how-tos/authorizing).\n\nDetermine your authentication type\n\nCheck the table below to see which **authentication type** is most appropriate\nfor your app:\n\n| Choose your OAuth2 authentication type | If ... |\n|----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Desktop app** | - You're managing all of your AdMob API accounts using a single top level manager account. - You're a first-time user, or want to get started quickly with the simplest setup. - Your app only authenticates Google AdMob users from one machine. |\n| **Web app** | - You want to authenticate as a user who can grant permission to your app to access their AdMob API account data. - You want to easily generate multiple authorization credentials, to manage third-party accounts for example. - Your app requires callback URLs. Callback URLs are not supported in the desktop app flow. |\n\n| **Key Point:** You can still choose the desktop app flow even if you're developing an app to run on a server. The difference is whether the OAuth authorization is completed locally or remotely. A desktop flow requires authorization to be completed on the local machine, whereas the web-flow lets authorization be completed on Google's authorization server.\n\nCreate a project\n\nTo get started using the AdMob API, you need to first create or select a\nproject in the Google API Console and enable the API using [the setup\ntool](https://console.cloud.google.com/start/api?id=admob.googleapis.com&credential=client_key),\nwhich guides you through the process and activates the AdMob API\nautomatically. \n\nEnabling the API for an existing project\n\nThe following steps apply to users who have an existing project and prefer to\nactivate the AdMob API for it manually.\n\nTo enable an API for your project:\n\n1. [Open the API Library](https://console.developers.google.com/apis/library) in the Google API Console.\n2. If prompted, select a project, or create a new one. The API Library lists all available APIs, grouped by product family and popularity.\n3. If the API you want to enable isn't visible in the list, use search to find it, or click **View All** in the product family it belongs to.\n4. Select the API you want to enable, then click the **Enable** button.\n5. If prompted, enable billing.\n6. If prompted, read and accept the API's Terms of Service.\n\nCreate OAuth2 credentials\n\nThe following instructions guide you through the process of creating an OAuth\n2.0 client ID to use with the [installed app\nflow](/identity/protocols/OAuth2InstalledApp).\n\n1. Go to the [Clients page](https://console.developers.google.com/auth/clients).\n2. Click **CREATE CREDENTIALS \\\u003e OAuth client ID**.\n\n If you hadn't configured an OAuth consent screen for this project\n previously, you'll be directed to do so now. Click **CONFIGURE CONSENT\n SCREEN**. There are multiple ways to configure your consent screen to\n use your OAuth 2.0 client ID.\n 1. Set your user type to **External** and publishing status to **Published**.\n 2. Or, set your user type to **External** and publishing status to\n **Testing** , then add **Test users** by selecting **add users** to\n give them access to use your OAuth 2.0 client ID.\n\n See additional information on [setting up your OAuth consent\n screen](//support.google.com/cloud/answer/10311615).\n3. Select **Desktop app** or **Web Application** as the application type, give\n it a name, then click **Create**.\n\nWhen done, you are presented with an OAuth 2.0 client ID and client secret,\nwhich you can download in JSON format and save for later use.\n\nMake a request\n\nThe AdMob API is built on HTTP and JSON, so any standard HTTP client can send\nrequests to it and parse the responses. However, the [Google API client\nlibraries](/admob/api/v1/libraries) provide better language integration,\nimproved security, and support for making authorized requests. The client\nlibraries are available in a number of programming languages; by using them you\ncan avoid the need to manually set up HTTP requests and parse the responses.\n| **Note:** The first time you activate the OAuth flow, you are asked to provide your AdMob publisher ID and accept an authorization prompt in your browser. Before accepting, make sure you're signed in with a Google Account that has access to your AdMob account. Your app is then authorized to access data on behalf of whichever account is currently logged in.\n\nWith [OAuth 2.0 credentials created](#credentials), you're ready to start using\nthe AdMob API. To request access using OAuth 2.0, your app also needs scope\ninformation:\n\n\n| Scope | Meaning |\n|--------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `https://www.googleapis.com/auth/admob.readonly` | See all AdMob data. This may include account information, inventory and mediation settings, reports, and other data. This doesn't include sensitive data, such as payments or campaign details. |\n| `https://www.googleapis.com/auth/admob.report` | See ad performance and earnings reports. See publisher ID, timezone, and default currency code. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nMake your first request to generate a report using examples in\n[Java](/admob/api/v1/reporting#java-client-library),\n[PHP](/admob/api/v1/reporting#php-client-library),\n[Python](/admob/api/v1/reporting#python-client-library) or\n[curl](/admob/api/v1/reporting#curl-command-line).\n\nRevoke shared tokens\n\nYou can revoke shared tokens in two ways:\n\n1. Navigate to your [Google account\n permissions page](//myaccount.google.com/permissions) and revoke access from\n the relevant project.\n\n2. Alternatively, you can revoke web application tokens using the [Google\n Identity API](/identity/protocols/oauth2/web-server#tokenrevoke)."]]