Wikimedia Api Strategyのロゴ

Wikimedia Api Strategy

コミュニティ
fuzheado
wikimedia-api-strategy

Choose the right Wikimedia API or tool for the task — a decision framework covering REST API, Action API, SPARQL, SQL database replicas, EventStreams, and Pywikibot, with latency/complexity/authentication trade-offs for each approach

概要

公開者fuzheado
リポジトリWikipedia-AI-Skills
スキル名wikimedia-api-strategy
スター
27
フォーク
10
同梱ファイル
4
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 4個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    fuzheadoがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルWikimedia Api StrategyをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikimedia-api-strategy
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fuzheado/Wikipedia-AI-Skills.git /tmp/Wikipedia-AI-Skills
mkdir -p .claude/skills
cp -r /tmp/Wikipedia-AI-Skills/.claude/skills/wikimedia-api-strategy .claude/skills/wikimedia-api-strategy
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでWikimedia Api Strategyを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にWikimedia Api Strategyを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Wikimedia Api Strategyは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

⚠️ User-Agent required: All API calls below need a descriptive User-Agent header. See the wikimedia-api-access skill for the correct format, rate limiting, and error handling. If you get HTTP 403 or 429, load that skill before debugging.

💡 Related skills:


Quick Decision Flowchart

What do you want to do?
│
├─ Read a single page or its summary?
│   → REST API (/page/summary, /page/html)       [fastest, simplest]
│
├─ Read multiple pages with filters?
│   ├─ Simple filter (by category, template, user)?
│   │   → Action API (list=categorymembers, etc.) [good for <500 items]
│   ├─ Complex relational query across entities?
│   │   → SPARQL (Wikidata Query Service)          [good for graph queries]
│   └─ Bulk analytics across millions of rows?
│       → SQL replicas (Toolforge database)        [100-1000× faster than API]
│
├─ Monitor changes in real-time?
│   → EventStreams (SSE)                           [only way for live data]
│
├─ Edit pages, run bots, or bulk operations?
│   → Pywikibot                                    [framework for all write ops]
│
└─ Check a page's patrol status or triage new pages?
    → PageTriage API                               [specialized extension]

Reference: The Six Access Methods

#MethodBest ForRead/WriteLatencyRate LimitAuth Needed?Base URL
1REST APISingle page reads, summaries, HTML contentRead onlyLow (~200ms)Per IPNohttps://en.wikipedia.org/api/rest_v1/
2Action APIMulti-page queries, filtering, metadata, editsRead + WriteLow (~200ms)200 req/s burst, 50 sustainedFor editshttps://en.wikipedia.org/w/api.php
3SPARQLComplex graph queries, cross-entity relationsRead onlyMedium (1-30s)1 req/s sustained, 60s timeoutNohttps://query.wikidata.org/sparql
4SQL ReplicasBulk analytics, JOINs across tables, aggregatesRead onlyMedium (~1s per query)Connection pool limitedSSH tunnel + DB credsVia Toolforge tunnel
5EventStreamsReal-time monitoring, live feedsRead onlyReal-time (push)None (server pushes)Nohttps://stream.wikimedia.org/v2/stream/
6PywikibotBot operations, bulk edits, frameworkRead + WriteVariesBot-specificBot passwordWraps Action API

Decision Trees by Task Category

A. Reading Page Content

If you need...Use...Because...
A page's first paragraph + thumbnailREST API (/page/summary/{title})Fastest, simplest JSON, no pagination
Full rendered HTML of a pageREST API (/page/html/{title})Pre-rendered, ready for CSS/JS parsing
Raw wikitext of a pageAction API (action=parse&prop=wikitext)REST API doesn't expose raw wikitext
Multiple pages' content at onceAction API with titles=TITLE1|TITLE2Batch up to 50 titles per call
A single revision's contentREST API (/revision/{id}/content)Direct by revision ID, no page lookup needed

❌ Common mistake: Using action=parse for a single page summary when the REST API's /page/summary returns cleaner JSON in one call.

⚠️ Extracting lead text for LLM context? Four approaches exist (REST summary, TextExtracts, Parsoid HTML + DOM cleaning, LLM summarization) and none is universally correct — they differ on fidelity, date/parenthetical loss, and artifacts. /page/summary silently strips parentheticals including dates (John Williams loses "(born February 8, 1932)"). See references/lead-text-extraction.md for the full decision matrix, the Parsoid noise contract, and the browser-render fidelity-test pattern.

B. Querying Multiple Pages with Filters

If you need...Use...Because...
Pages in a category (flat)Action API (list=categorymembers)Direct, paginated, namespace filterable
Pages in a category tree (recursive)Action API with cmtype=page|subcat loop, or SQL replicas (faster)The API is simpler but slower; SQL is 100× faster for deep trees
Pages using a templateAction API (list=embeddedin)Direct eititle parameter, paginated
Pages edited by a userAction API (list=usercontribs)Direct ucuser parameter, date-range filterable
Pages matching a text searchAction API (list=search) or REST API (/search/page)REST API returns cleaner results; Action API supports more filters
Complex cross-page analytics (e.g., "pages in Category:Physics sorted by pageviews with quality assessments")SQL replicasWould require 500+ API calls. One SQL query with JOINs handles it in seconds.

❌ Common mistake: Using list=categorymembers + individual API calls per page for analytics (e.g., fetching pageviews for 100 articles). Instead: use SQL replicas for the JOIN, or SPARQL + batch pageviews call.

C. Graph Queries and Structured Data

If you need...Use...Because...
"Find all X that have property Y"SPARQLOne query replaces N API calls
Cross-language article mappingSPARQL (schema:about/schema:isPartOf)Sitelinks are not queryable via regular properties
Items missing a property (e.g., no image)SPARQL (FILTER NOT EXISTS)Can't express "does not have" in the Action API
Simple property lookup for a known itemAction API (wbgetentities)Faster than SPARQL for single-item lookups
Batch entity classification (e.g., "which of these 100 items are people?")Action API (wbgetentities batch of 50)Faster than 100 SPARQL calls; use SPARQL only if you need subclass traversal

❌ Common mistake: Using SPARQL for single-item lookups. wbgetentities returns the same data in ~200ms vs SPARQL's ~2-30s.

D. Bulk Data and Analytics

If you need...Use...Because...
Top 100 most-viewed pages in a categorySQL replicas (page_props JOIN categorylinks)One query. Equivalent API approach would require: (1) fetch category members, (2) fetch pageviews for each = 100+ API calls
Correlation between quality and pageviewsSQL replicas (page_assessments JOIN page_props)Single JOIN vs hundreds of API calls
Count of articles by quality class for a WikiProjectSQL replicasSELECT pa_class, COUNT(*) ... GROUP BY pa_class in seconds
Quick sort by pageviews for a small set (<50 articles)REST API (/pageviews/per-article/...)Simpler than setting up a database tunnel
One-time ad-hoc analysis of a few articlesAction APINo SSH tunnel setup needed

❌ Common mistake: Using the API for what should be a database query. If you find yourself writing a loop that makes >50 API calls for the same type of data, switch to SQL replicas or SPARQL.

E. Real-Time Monitoring

If you need...Use...Because...
Watch edits as they happenEventStreams (recentchange stream)Only way to get sub-second notifications
Monitor new page creationsEventStreams (filter type == "new")Faster than polling list=recentchanges
Build a live dashboardEventStreams + periodic API snapshotsStream gives live data, API fills history
Historical replay of past eventsEventStreams (?since= parameter)Up to 31 days of replay available
Check if a specific page was recently editedAction API (prop=revisions&rvlimit=1)Simpler than consuming a stream for one check

❌ Common mistake: Polling list=recentchanges every few seconds instead of using EventStreams. Polling wastes API rate limits and introduces latency. The stream pushes data instantly.

F. Editing and Bot Operations

If you need...Use...Because...
Make a single editAction API (action=edit)Simple, no framework setup needed
Make many edits with consistent logicPywikibotBuilt-in rate limiting, edit summaries, conflict detection, page generators
Bulk template replacement across a categoryPywikibot (replace.py script)Ready-made script, handles page loading/saving/conflicts
Scrape infobox data into WikidataPywikibot (harvest_template.py script)Purpose-built for this exact workflow
Move/delete pages in bulkPywikibot (built-in scripts)Handles redirects, rate limits, and error recovery
Upload media to CommonsPywikibot (image_transfer.py)Preserves attribution history across wikis

❌ Common mistake: Writing raw action=edit API calls for bulk operations. Pywikibot handles throttling (put_throttle), edit conflict detection, and automatic retry — all of which you'd need to implement from scratch with the raw API.


Performance Comparison: API vs. SQL for the Same Task

This table shows how much work each approach requires for an equivalent result:

TaskAction APISPARQLSQL ReplicasSpeed Ratio
Top 50 articles in a category by pageviews50-200 calls (category + pageviews per article)1 query (with pageview data caveats)1 query (JOIN)API:SQL ≈ 1:200
Count articles by quality class for a WikiProject1 call per assessment × N pages1 query (if items have P31)1 query (GROUP BY)API:SQL ≈ 1:500
"Find all physicists born before 1900"Not feasible (would need to scan all pages)1 queryComplex (would need wikidata IDs)SPARQL:API ≈ 1:∞
Fetch 10 random article summaries1 call (REST API, 10 titles)OverkillOverkillREST is fastest
Monitor new pages for 1 hour360 polls × API callsNot applicableNot applicableEventStreams:API ≈ 1:360

💡 Rule of thumb: If your task involves more than 50 individual items, consider whether a single SPARQL query or SQL query could replace the loop.


SOP: Strategy Selection in Practice

Step 1: Define Your Task

Is it:
  A single page/entity?       → Method 1 or 2
  A batch of related items?   → Method 2, 3, or 4
  A complex relation?          → Method 3 (SPARQL)
  Bulk analytics?              → Method 4 (SQL)
  Real-time?                   → Method 5 (EventStreams)
  Writing/editing?             → Method 6 (Pywikibot) or 2 (Action API)

Step 2: Check Constraints

Do you have:
  Database access (SSH + credentials)?   → SQL replicas available
  A registered bot account?              → Pywikibot available (higher rate limits)
  No authentication at all?              → REST/Action API (read-only), SPARQL, EventStreams
  A need for speed?                      → REST API (fastest for reads), SQL (fastest for analytics)

Step 3: Combine When Necessary

Some of the most powerful workflows combine methods:

1.  Action API (categorymembers)  →  Get list of articles
2.  + SPARQL (sitelinks)          →  Cross-reference with Wikidata
3.  + REST API (pageviews)        →  Rank by popularity
4.  + Pywikibot (editing)         →  Act on the results

Or an even faster alternative using SQL:

1.  SQL replicas (JOIN)           →  All analytics in one query
2.  + Pywikibot (editing)         →  Act on the results

Step 4: Avoid Common Anti-Patterns

❌ Anti-PatternWhy✅ Better Approach
Polling list=recentchanges every 5 secondsWastes rate limit, misses eventsUse EventStreams for push-based monitoring
Fetching pageviews for 100+ articles one by one via REST API100+ API calls, takes minutesUse SQL page_props JOIN or batch the API calls
SPARQL query for a single known QID2-30s response time for a 200ms taskUse wbgetentities via Action API
Raw action=edit for a 1000-page template migrationNo throttling, no conflict handling, no edit summary enforcementUse Pywikibot replace.py
Looping through category members with individual API calls per pageN+1 query problemUse SQL replicas or batch API calls
Fetching full page wikitext just to get the page IDWasteful — ridiculously oversized responseUse prop=info&inprop=url (much smaller response)
Using the Action API when you need rendered HTMLReturns raw wikitext, requires client-side renderingUse REST API /page/html/{title} for ready-to-render HTML
Caching batched API responses by URL, then changing the batchingBatch composition is part of the cache key, so a "harmless" refactor invalidates every entry and triggers a full re-crawl — which can trip a rate limitCache per entity alongside the URL cache, and migrate the existing batch cache instead of re-fetching. See wikimedia-api-access
Implementing your own bot frameworkYou'll rewrite Pywikibot's throttling, conflict detection, and page generators from scratchUse Pywikibot — it has 20+ years of battle-testing
Searching edit summaries via any APINo API indexes edit summaries. CirrusSearch indexes page content only. list=recentchanges/list=usercontribs return summaries but have no filter parameter for summary text.Use SQL replicas with actor_name + date constraints, the Σ Toolforge tool (sigma/summary.py), or XML dumps. See wikimedia-database references/edit-summary-search.md.
Using rvlimit in multi-title batch queriesThe API rejects rvlimit when multiple pages are supplied: "rvlimit may only be used on a single page". The response is a 400 error, not partial data.Omit rvlimit from multi-title queries. The default is 1 revision per page — usually sufficient. Fetch full history per-page individually if you need more.
Fetching many large pages in a single titles= query via tools with stdout capsTerminal-based API clients (curl piped through a tool with a ~50KB output cap) silently truncate large multi-page responses. JSON parsing fails on the truncated output with no clear error. The first 2-3 pages parse fine; the rest are lost.Fetch pages individually or in batches of 2-3. For talk pages especially (which can be 200K+ chars), one-at-a-time is safest. Use --data-urlencode with -G for curl to handle pipe chars in titles=.
Scraping listing/category pages to find structured discussions (RFCs, AfDs, etc.)Manually-curated listing pages (e.g. Wikipedia:Requests for comment/All) lag behind or miss entries. They're also harder to parse reliably.Use list=embeddedin&eititle=Template:Rfc (or the relevant template) to find ALL pages currently transcluding the template. This is the bot-tracked source of truth — every active RFC has the template. See references/template-transclusion-discovery.md.

Appendix: Quick Reference Cards

Read Operations — Fastest Path by Data Size

1-10 items     → REST API (single calls)
10-500 items   → Action API (batch parameters, list modules)
500-5000 items → SPARQL (one query) or Action API (paginated)
5000+ items    → SQL replicas (single JOIN/aggregation query)

Write Operations — By Scale

1 edit         → Action API (action=edit, simplest)
10-100 edits   → Pywikibot (custom script with page generator)
100+ edits     → Pywikibot (built-in scripts like replace.py, harvest_template.py)

Real-Time Data

Live monitoring     → EventStreams (SSE push)
Periodic checks     → Action API (polling, but minimize frequency)
Historical replay   → EventStreams (?since= parameter, up to 31 days)

Authentication Requirements

Read-only, no auth     → REST API, Action API (query), SPARQL, EventStreams
Read + Write           → Bot password (Action API) or OAuth (Pywikibot)
SQL replicas           → Toolforge SSH key + database credentials
Higher rate limits     → OAuth (Lift Wing, REST API) or bot flag (Pywikibot)

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Wikimedia Api Strategy」では何ができますか?

Choose the right Wikimedia API or tool for the task — a decision framework covering REST API, Action API, SPARQL, SQL database replicas, EventStreams, and Pywikibot, with latency/complexity/authentication trade-offs for each approach

TypingMindでWikimedia Api Strategyを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Wikimedia Api Strategyはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにWikimedia Api Strategyをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikimedia-api-strategyを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Wikimedia Api Strategyを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Wikimedia Api Strategyは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもWikimedia Api Strategyを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Wikimedia Api Strategy」は無料ですか?

はい。fuzheadoがGitHubでMITライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇