Help:Contributing/api: Difference between revisions
Jump to navigation
Jump to search
docs: migrate contribution guide §8 (API and bulk editing) from docs/contribution-guide.md (via create-page on MediaWiki MCP Server) |
Rewrite in code-guide style: strip translation markup, <code> for plain tokens (via update-page on MediaWiki MCP Server) |
||
| Line 1: | Line 1: | ||
< | The full Wikibase API is available at <code>https://wikibase.ronzz.org/api.php</code>. It requires login and a CSRF token. This page is for editors who want to script or bulk-edit; for interactive editing, see [[Help:Contributing/entities]]. | ||
Log in and get a CSRF token (adjust the credentials): | Log in and get a CSRF token (adjust the credentials): | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| Line 28: | Line 20: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Key API actions: <code>wbeditentity</code> (create/update), <code>wbgetentities</code> (read), <code>wbcreateclaim</code>/<code>wbsetclaim</code> (statements), <code>wbsearchentities</code> (find by label), <code>wbremoveclaims</code>. A REST API is also available under <code>/w/rest.php/wikibase/</code>. | |||
Key API actions: < | |||
== | == Bulk tools == | ||
These tools are not installed on the instance — run them from your own machine: | These tools are not installed on the instance — run them from your own machine: | ||
* [https://github.com/LeMyst/WikibaseIntegrator WikibaseIntegrator] (Python) | * [https://github.com/LeMyst/WikibaseIntegrator WikibaseIntegrator] (Python) | ||
* [https://www.mediawiki.org/wiki/Manual:Pywikibot Pywikibot] (official manual) | * [https://www.mediawiki.org/wiki/Manual:Pywikibot Pywikibot] (official manual) | ||
* [https://www.wikidata.org/wiki/Help:QuickStatements QuickStatements] (spreadsheet-style batch) | * [https://www.wikidata.org/wiki/Help:QuickStatements QuickStatements] (spreadsheet-style batch) | ||
== | == See also == | ||
* [[Help:Contributing]] — the hub | |||
* | |||
* [https://www.mediawiki.org/wiki/Wikibase Wikibase documentation] (official) | * [https://www.mediawiki.org/wiki/Wikibase Wikibase documentation] (official) | ||
* [https://www.wikidata.org/w/api.php action=wb…] API reference (Wikidata) | * [https://www.wikidata.org/w/api.php action=wb…] API reference (Wikidata) | ||
Revision as of 17:28, 19 August 2026
The full Wikibase API is available at https://wikibase.ronzz.org/api.php. It requires login and a CSRF token. This page is for editors who want to script or bulk-edit; for interactive editing, see Help:Contributing/entities.
Log in and get a CSRF token (adjust the credentials):
# 1) Log in
curl -s -c /tmp/wb.cookies "https://wikibase.ronzz.org/api.php" \
--data-urlencode "action=query" --data-urlencode "meta=tokens" \
--data-urlencode "type=login" --data-urlencode "format=json"
# …POST action=login with lgname/lgpassword/lgtoken, then:
TOKEN=$(curl -s -b /tmp/wb.cookies "https://wikibase.ronzz.org/api.php?action=query&meta=tokens&format=json" \
| python3 -c "import json,sys; print(json.load(sys.stdin)['query']['tokens']['csrftoken'])")
# 2) Create an item (wbeditentity)
curl -s -b /tmp/wb.cookies "https://wikibase.ronzz.org/api.php" \
--data-urlencode "action=wbeditentity" --data-urlencode "new=item" \
--data-urlencode "token=$TOKEN" \
--data-urlencode 'data={"labels":{"en":{"language":"en","value":"My first item"}}}' \
--data-urlencode "format=json"
Key API actions: wbeditentity (create/update), wbgetentities (read), wbcreateclaim/wbsetclaim (statements), wbsearchentities (find by label), wbremoveclaims. A REST API is also available under /w/rest.php/wikibase/.
Bulk tools
These tools are not installed on the instance — run them from your own machine:
- WikibaseIntegrator (Python)
- Pywikibot (official manual)
- QuickStatements (spreadsheet-style batch)
See also
- Help:Contributing — the hub
- Wikibase documentation (official)
- action=wb… API reference (Wikidata)