API:Tutorial/ar

سوف تتعرف في هذا الدليل التوجيهي على واجهة برمجة التطبيقات لتطبيق Action على ميدياويكي وكيفية استخدامها وطلب الصيغة وإجراء استفسار بسيط وأمثلة على المشاريع التي تستعين بواجهة برمجة التطبيقات لتطبيق Action.

شاهد تطبيقات تقديمية على مصنع الأدوات «Toolforge»

نظرة عامة على واجهة برمجة التطبيقات لتطبيق Action على ميدياويكي
إن واجهة برمجة التطبيقات لتطبيق Action على ميدياويكي هي خدمة وب من نوع REST تسمح للمستخدمين بإجراء أعمال ويكي معينة مثل إنشاء الصفحات والتصديق والتحليل اللغوي والبحث وخلافه. هي نقطة بداية طيبة كي تستوعب واجهة برمجة التطبيقات هذه.

يرسل برنامجك طلبات إلى واجهة برمجة التطبيقات للوصول إلى سمات الويكي. مثال ذلك تسجيل الدخول إلى موقع ويكي أو إنشاء صفحة وتعديلها أو البحث عن عنوان أو البحث عن نص في المحتوى أو تحليل المحتوى لغويا. إن واجهة برمجة التطبيقات لتطبيق Action متاحة للمطورين من الغير ومطوري امتدادات ويكيميديا وإداري مواقع الويكي.

On the right sidebar of this page, there are many features that are supported by the API, grouped by category. Before sending requests to a wiki server, first read through the overview pages such as data formats, errors and warnings, and the Action API FAQ.

كيفية استخدام واجهة برمجة التطبيقات لتطبيق Action على ميدياويكي
You can request for data from client side to the server over HTTP and get the response back in a standard format (typically JSON). A request consists of an endpoint and a set of parameters. There are two types of request that can be made: GET and POST. For a GET request, a parameter would contain a query string in the URL. For a POST request, format the parameters in JSON format.

طلب الصيغة
All Wikimedia Wikis have endpoints in this format. To operate on the MediaWiki main site or English Wikipedia, use the related endpoint. For example, the English Wikipedia is at  For testing new accounts or test edits to pages, use the test wiki endpoint.

In the query string in the URL, add the  parameter. It tells the API which action to perform. The most popular action is  (the URL would contain ), which allows fetching data from a wiki. Following the  parameter, add another parameter to indicate which one of the three query module types you want to perform:

get meta information about the wiki and user
 * - get properties of pages
 * - get list of pages matching a certain criterion

Finally, include the  parameter, which tells the API in which format to get the results. The recommended format is JSON. The API has supported other output formats in the past, but they are not generally recommended.

استفسار بسيط
Let’s take an example of a simple query to understand what a typical GET request and response would look like in the context of the Action API.

Let's search for a title in a wiki. We will use the  module documented on.

طلب GET
To search for page titles or content matching, the URL for the HTTP GET request would be: Explanation of each part of the URL:

indicates JSON output, which is the recommended output format.
 * is the main endpoint. In this case it is English Wikipedia.
 * means fetch data from wiki.
 * means get list of pages matching a criteria.
 * indicates the page title or content to search for. The  indicates a space character in a URL.

Response
The response is a JSON format document with a list of pages titles that match Craig Noone :

Examples of projects using Action API
Some example of projects in Wikimedia that use Action API:


 * Wikipedia iOS App, in which one of the features is to search for wiki pages near your location.


 * Bots that operate on a wiki. Pywikibot is a bot framework written in Python that interfaces with MediaWiki API which a lot of bot developers use.

API use in visualizing data obtained from a wiki. Such as this neat visualization that shows real time edits made on Wikipedia.

Additional notes
All data modifying actions such as logging, editing or moving a page, and watching or patrolling changes would require tokens. You would need to obtain tokens via to proceed further.
 * Several sites are using MediaWiki. They might all be running a different version of MediaWiki and in turn the API. Some module parameters supported in one version might be deprecated or removed in others. You could learn about that in each module's documentation via API help module.
 * If you want to make a lot of API calls, and perhaps run very busy and active bots, talk to wiki admins ahead of time, so they do not block you. See list of Administrators of Wikimedia projects. Read more about this topic on.

Resources

 * Use Special:APISandbox to experiment with the Action API. You can play around with supported actions, specify a value for parameters, and send requests to the API to see the results on the same page.
 * Wikimedia dumps so you can work with them locally.
 * Read through tutorials: An Introduction to API's and What is REST — A Simple Explanation for Beginners.
 * MediaWiki API help provides auto-generated API documentation of all supported modules.
 * provides an overview of the Action API.
 * Introduction to the MediaWiki API by User:Roan_Kattouw_(WMF) at the San Francisco Hackathon, 2012. This tutorial guide goes along with the video.
 * GitHub: MediaWiki API Demos