Jump to content

API:よくある質問

From mediawiki.org
This page is a translated version of the page API:FAQ and the translation is 56% complete.

概要

このページでは、 MediaWiki Action APIに関するよくある質問に対する回答を示します。 This page is intended for technical contributors and software developers who wish to understand and use the MediaWiki Action API.

API:メインページ も参照してください。このページで回答されていない質問にも回答しており、その他の有用なページヘのリンクもあります。

API について

APIとは

APIは Application Programming Interface の頭字語です。これにより、さまざまなアプリケーションが相互に通信できます。 Sometimes an API allows an application to request an action to be done by the application which implements the API. MediaWikiの一般的な用語では、HTTPリクエスト応答メカニズムを使用し、JSON/XML構造化データを生成するweb-based APIsを指します。

REST API とは

REST is an acronym for REpresentational State Transfer. A set of guiding principles or constraints define a RESTful system. A RESTful API — or just a REST API — adheres to these principles and hence is a faster, more reliable and scalable service.

API ができること

APIの使用法を参照。

APIの詳細情報はどこにある?

幾つかのリソース :

全般

MediaWiki操作APIとは

The MediaWiki Action API is a RESTful web service that allows users to perform certain wiki-actions like page creation, authentication, parsing, searching, etc.

MediaWiki APIの使用目的は?

MediaWiki操作APIは以下のように使用します :

  • Wikiの機能にアクセス。
  • interact with a wiki.
  • obtain meta-information about wikis and public users.

The right sidebar points to many features supported by the API. Also, see some Wikimedia projects that use the MediaWiki Action API.

MediaWiki Action APIの使用方法は?

HTTP requests are usually used to call the Action API. For detailed instructions, read the tutorial.

Action APIを使用するには :

  • Special:ApiSandboxを使ってください。
  • ブラウザの開発者コンソールを開き、wikiを操作しながらapi.phpへのネットリクエストをみてみましょう。

モジュール、サブモジュール、パラメータとは?

The MediaWiki Action API has numerous modules that we use to perform different tasks. In technical terms, a module is a subclass of ApiBase. A module requires parameters. These parameters may (or may not) be submodules.

以下のリクエストを考えてみます:

here:

Also, see Introduction and guidelines. It describes the submodules of the action=query module.

How do I know which module and submodule to call?

MediaWiki Action APIは大きく、拡張機能によってさらに拡大することができます。 APIクエストを処理する方法をいくつかご紹介します:

  • In the sidebar, look for the feature you wish to implement and follow the link for information about which modules to call.
  • The self-documenting API pages contain a list of all modules and submodules with brief descriptions. You can start at the main module and follow the links to different submodules. (Append recursivesubmodules=1 to view the expanded version)

APIモジュールを使用するためのサンプルコードはどこ?

The API documentation pages contain an 'Examples' section to demonstrate how different modules and submodules can be used. The auto-generated docs also have examples trailing the module descriptions.

See Mediawiki-API-demos for code snippets in Python and JavaScript.

出力する際のフォーマットのコントロールの仕方は?

The default output format is JSON. Other output formats have been deprecated or removed in the latest stable MediaWiki version, and their use is discouraged.

In older versions, to control the output format, you can pass &format=someformat in the query string.

詳しくはAPI:データ形式

アクセストークンは必要?

You will require an access token to perform data modifying actions like logging in, editing, moving pages, etc.

To learn more, refer to API:Tokens or the sidebar category 'Authentication'.

APIを使用したクロスサイトリクエストはどう行う?

You must use JSONP or CORS to make cross-site requests in MediaWiki.

For details, see API:Cross-site requests.

クエリの結果に制限はあるか?

Yes, it depends on the query parameter. For example, the results for list and property queries cannot exceed 500 for regular users. The API pages contain information about these limits in the 'Additional notes' section or the 'Limits' section. Note that some modules impose stricter limits under certain conditions.

If you are unsure about what limit to set and just want as many results as possible, set the limit to max.

API呼び出しに制限は?

There is no concrete limit. Yet, we recommend making a reasonable number of calls to prevent getting blocked. If you want to make many requests, contact the administrators beforehand.

API:エチケットも参照。

MediaWiki Action APIのアップデート方法は?

You can subscribe to the MediaWiki-API-Announce mailing list for announcements and updates.

ウィキダンプとは何で、どのように使うの?

Wikimedia’s data dumps are dumps of wiki collections, content, metadata, search indices, etc. To work with dumps, see using dumps and public dumps.


さらなるHelpはどこに?

If you can't find answers in the MediaWiki API documentation or the auto-generated documentation pages, feel free to reach out in the following ways.

拡張機能の開発者とウィキ所有者

How can I create an API module in an extension?

API:Extensions will walk you through the complete process of creating an API module in an extension.

APIの内部構造は?

API:Implementation Strategy explains the implementation of the API machinery in MediaWiki Core.

APIの使用を制限するには?

To restrict the API usage, you can either restrict the use of write API or disable individual modules.

For instructions and examples, see API:Restricting API usage.

エラーとトラブルシューティング

エラーの検出方法

If you encounter an error, the error response from the API will set the MediaWiki-API-Error HTTP header and return an error structure.

このエラーの意味は?

Find your error in the list of standard error messages to understand what the error means.

バグ報告/機能提案はどこに出せばいい?

You can report bugs and file feature requests on Wikimedia's task tracking tool, Phabricator.

注:

See How to report a bug for more details.

APIのバージョンによりエラーが発生しているのですが?

If a website runs a different version of MediaWiki, it would also run a different version of the API. Some module parameters supported in one version might be deprecated (or removed) in others. Such parameters will throw an exception if used. The API pages document any such deprecations.

See the release notes for information regarding different API versions.