API:Etiquette/ja

This page contains the best practices that should be followed when using the API.

リクエストの上限
There is no hard and fast limit on read requests, but be considerate and try not to take a site down. Most system administrators reserve the right to unceremoniously block you if you do endanger the stability of their site.

Making your requests in series rather than in parallel, by waiting for one request to finish before sending a new request, should result in a safe request rate. It is also recommended that you ask for multiple items in one request by:


 * Using the pipe character whenever possible e.g. , instead of making a new request for each title.
 * Using a instead of making a request for each result from another request.


 * Use GZip compression when making API calls by setting  to reduce bandwidth usage.

Requests which make edits, modify state or otherwise are not read-only requests, are subject to rate limiting. The exact rate limit being applied might depend on the type of action, your user rights and the configuration of the website you are making the request to. The limits that apply to you can be determined by accessing the action=query&meta=userinfo&uiprop=ratelimits API endpoint.

When you hit the request rate limit you will receive a with the error code. When you encounter this error, you may retry that request, however you should increase the time between subsequent requests. A common strategy for this is Exponential backoff.

版の構文解析
パラメーターで版番号を指定して結果を取得するクエリを実行することもできますが、これはサーバーにとって負荷が高い処理です. 特定の版を取得するには、 パラメーターを使用します. 例:

maxlag パラメーター
タスクが対話的ではない場合 (つまり、利用者が処理結果を待機しない場合) は、 パラメーターを使用すべきです. The value of the  parameter should be an integer number of seconds. For example:

これにより、サーバーの負荷が高い場合に、タスクの実行を防止できます. Higher values mean more aggressive behavior, lower values are nicer.

See for more details.

User-Agent ヘッダー
It is best practice to set a descriptive User Agent header. To do so, use. For example in PHP:

人気があるウェブ ブラウザーの User-Agent をコピーしないでください. これにより、問題が発生した場合に発生源を特定するのが容易になります.

If you are calling the API from browser-based JavaScript, you may not be able to influence the  header, depending on the browser. To work around this, use the  header.

詳細は m:ユーザーエージェントのポリシー を参照してください.

Data formats
All new API users. See for more details.

Performance
If you are getting results more slowly than you would like, read the to help you think about performance generally.

If reading via the API rather than directly reading from databases is impeding your client's performance, consider whether to put it into Wikimedia's Toolforge.