The ProofreadPage extension provides read/write access to index categories and fields in both Wikitext and JSON[1]. Usually, for API access, JSON is easier.
Index field and category data is both stored in the main slot of an index page[2].
Note that while you can choose the content format, the content model of an index page is always proofread-index
.
Read the main slot content with action=parse
(see API:Parse), setting contentformat
as you wish:
application/json
(as of 29 Oct 2022, this is currently broken, see phab:T321446)text/x-wiki
(default if not given){ "action": "parse", "format": "json", "formatversion": 2, "page": "Index:Sandbox.djvu", "prop": "wikitext", "contentformat": "application/json" }Response
{ "parse": { "title": "Index:Sandbox.djvu", "pageid": 3, "wikitext": "{\"fields\":{\"Type\":\"book\",\"wikidata_item\":\"\",\"Title\":\"Pericles\",\"Language\":\"en\",\"Volume\":\"1\",\"Author\":\"[[Pericles]]\",\"Translator\":\"\",\"Editor\":\"Editor name\",\"Illustrator\":\"\",\"School\":\"\",\"Publisher\":\"\",\"Address\":\"\",\"Year\":\"\",\"Key\":\"\",\"ISBN\":\"\",\"OCLC\":\"\",\"LCCN\":\"\",\"BNF_ARK\":\"\",\"ARC\":\"\",\"Source\":\"_empty_\",\"Image\":\"1\",\"Progress\":\"X\",\"Pages\":\"<pagelist\\n1=Cover\\n2=1 \\/>\",\"Volumes\":\"\",\"Remarks\":\"\",\"Width\":\"\",\"Css\":\"\",\"Header\":\"\",\"Footer\":\"\"},\"categories\":[\"Other cat\"]}" }, }
Specifically, the wikitext
field contains serialised JSON. You can deserialise this and manipulate it, then write it back.
This is done with the usual edit
action (see API:Edit).
{ "action": "edit", "format": "json", "formatversion": "2" "title": "Index:Peri.djvu", "text": "{\"fields\":{\"Type\":\"book\",\"wikidata_item\":\"\",\"Title\":\"Pericles\",\"Language\":\"en\",\"Volume\":\"1\",\"Author\":\"[[Pericles]]\",\"Translator\":\"\",\"Editor\":\"Editor name\",\"Illustrator\":\"\",\"School\":\"\",\"Publisher\":\"\",\"Address\":\"\",\"Year\":\"\",\"Key\":\"\",\"ISBN\":\"\",\"OCLC\":\"\",\"LCCN\":\"\",\"BNF_ARK\":\"\",\"ARC\":\"\",\"Source\":\"_empty_\",\"Image\":\"1\",\"Progress\":\"X\",\"Pages\":\"<pagelist\\n1=Cover\\n2=1 />\",\"Volumes\":\"\",\"Remarks\":\"\",\"Width\":\"\",\"Css\":\"\",\"Header\":\"\",\"Footer\":\"\"},\"categories\":[\"Other cat\"]}", "contentformat": "application/json", }
You will need to provide a valid token to perform any edit
action.
{ "edit": { "result": "Success", "pageid": 3, "title": "Index:Peri.djvu", "contentmodel": "proofread-index", "nochange": true, "watched": true }, }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4