Page MenuHomePhabricator

Document the Wikidata API in the Developer Hub
Closed, ResolvedPublic

Description

Use what's in api.php and https://www.mediawiki.org/wiki/Wikibase/API to write up a guide for using the Wikidata part of the MediaWiki web API.

Details

Reference
fl544
TitleReferenceAuthorSource BranchDest Branch
Remove Google spreadsheets integrationrepos/movement-insights/movement-metrics!17nshahquinn-wmfwork/nshahquinn-wmf/remove-spreadsheets-integrationmain
Update function-schemata sub-module to HEAD (50415ed)repos/abstract-wiki/wikifunctions/function-orchestrator!189apinesync-function-schematamain
Update function-schemata sub-module to HEAD (50415ed)repos/abstract-wiki/wikifunctions/function-evaluator!225apinesync-function-schematamain
Resolve list types in order to get type converters for list elements.repos/abstract-wiki/wikifunctions/function-orchestrator!188apineapine-list-type-conversionmain
Support type converters for the elements of typed lists.repos/abstract-wiki/wikifunctions/function-evaluator!224apineapine-list-of-type-convertersmain
Add Avro binary format v0.1.1: support type converters of list types.repos/abstract-wiki/wikifunctions/function-schemata!122apineapine-community-defined-listmain
[jobs-api] create seperate api.py and move flask things thererepos/cloud/toolforge/jobs-api!91raymond-ndibesplit_logic_from_apimain
jobs-api: bump to 0.0.305-20240604072701-b6dec32drepos/cloud/toolforge/toolforge-deploy!300project_1317_bot_df3177307bed93c3f34e421e26c86e38bump_jobs-apimain
webserver/build-webserver-image: Don't use php symlinkrepos/releng/release!76dancymain-Idfd11f8c0d1bcc12ecf5cc002a5bd41af2016a33main
Refactor Wikicharts code to follow Python conventions, streamline imports,...repos/movement-insights/movement-metrics!15hghaniwikicharts_refactormain
Remove "unclassed" region from geographic content gap metricsrepos/movement-insights/movement-metrics!11nshahquinn-wmfwork/nshahquinn-wmf/remove_unclassed_regionmain
deploy: create-database: Don't use /srv/mediawiki-staging/php symlinkrepos/releng/train-dev!70dancymain-I678fbc30538ec332b0ca4d8928c77424c3ffbe52main
Configure team-specific alert emailsrepos/data-engineering/airflow-dags!664nshahquinn-wmfanalytics_product_configmain
Disable /srv/mediawiki-staging/php symlink managementrepos/releng/train-dev!64dancymain-I38bcc3e3c06164fe9871594bda13c1a27b7b33cemain
Revert "Create team-specific EasyDAG templates"repos/data-engineering/airflow-dags!653nshahquinn-wmfwork/nshahquinn-wmf/revert_split_configmain
Add manage_mediawiki_php_symlink config flagrepos/releng/scap!277dancymaster-Ia0f2289242f8627821fd2ac8accec1817af7cdebmaster
Create team-specific EasyDAG templatesrepos/data-engineering/airflow-dags!651nshahquinn-wmfwork/nshahquinn-wmf/split_analytics_product_configmain
jobs-api: bump to 0.0.291-20240415170518-fde04b2crepos/cloud/toolforge/toolforge-deploy!259project_1317_bot_df3177307bed93c3f34e421e26c86e38bump_jobs-apimain
deploy: Add http://www.mediawiki.org/ontology/ontology.owl httpbb testrepos/releng/train-dev!56dancymain-Ide3492d2ca4c558c0eff54a8459b48942031b536main
Use static.php to serve www.mediawiki.org/ontology/ontology.owl (v2)repos/releng/train-dev!54dancymain-I991d969dd9343126661d3d6e9159588cb00855famain
Show related patches Customize query in GitLab

Event Timeline

flimport raised the priority of this task from to Medium.Sep 12 2014, 1:45 AM
flimport added a project: Web-APIs-Hub.
flimport set Reference to fl544.
Qgil lowered the priority of this task from Medium to Low.Oct 22 2014, 6:20 PM
chasemp mentioned this in Unknown Object (Diffusion Commit).Nov 15 2014, 12:56 AM
chasemp mentioned this in Unknown Object (Diffusion Commit).Dec 10 2014, 8:37 PM

I would argue this is not "low" as the API is one of the most important parts of Wikidata.

I set the priority to Low when Sumana left and we had no technical writer to work on this. Now that we have @Spage, things may change. In fact, he is committing to work on T88409 this month, which is blocked by this task. We are planning our ECT monthly sprint today.

In any case, could the Wikidata team assign someone to help S documenting this API and finding good showcases, and documentation in general? I agree with Lydia that this is an area we should prioritize. When I go somewhere public with developers I always get questions about the Wikidata API (last time this weekend at FOSDEM, repeated times).

Cool. @Lucie can hopefully help. Maybe also @Addshore wants to be involved.

*waves* I probably don't have much time to do the writing but will happily read and review it all / point out missing things!

Spage raised the priority of this task from Low to Medium.
Spage added a project: ECT-February-2015.
Spage set Security to None.

I wonder how these Wikidata API docs will look like, and where will be they published.

In the masterplan, we have agreed that API references should be documented directly in the source code, using the best tool for output. In the case of Wikidata, these APIs are extended MediaWiki APIs. They are referenced in https://www.wikidata.org/w/api.php mixed with all the rest. What is the best way to show them to 3rd party developers willing to learn only about these APIs?

On the other hand, we have https://www.mediawiki.org/wiki/Wikibase/API which I guess is written manually. Will we keep this duplication?

PS: this is the type of problems that the new Developer Hub needs to solve.

In T359#1013892, @Qgil wrote:

I wonder how these Wikidata API docs will look like, and where will be they published.

In the masterplan, we have agreed that API references should be documented directly in the source code, using the best tool for output. In the case of Wikidata, these APIs are extended MediaWiki APIs. They are referenced in https://www.wikidata.org/w/api.php mixed with all the rest.

BTW you can show the generated API documentation for a single action with a parameter, e.g. https://www.wikidata.org/wiki/Special:ApiHelp/wbgetentities

What is the best way to show them to 3rd party developers willing to learn only about these APIs?

I think an on-wiki introduction with motivation and explanation is the way to go. The generated API doc could have a substantial intro explaining items, snaks, etc. but it would have to be repeated for each wikibase API action and we'd need to reproduce wiki markup for sectioning and linking. I'm undecided whether to have examples both in the API, and in the wiki page (T88755: Improve MediaWiki API example behavior).

On the other hand, we have https://www.mediawiki.org/wiki/Wikibase/API which I guess is written manually. Will we keep this duplication?

Per above, yes.
What's confusing me is that page is currently full of generic API documentation and nothing relevant to wikibase! The May 2014 version talks about Wikibase , has helpful advice, and good examples, etc., but then @Christopher (Johnson of WMDE) replaced it with "Please see wikidata.org/w/api.php for a perfectly up to date copy" and then User:D konto (Dionysia Kontotasiou) added a bunch of generic information. I'll revive the May 2014 revision.

PS: this is the type of problems that the new Developer Hub needs to solve.

indeed!

The problem was that the page was out of date and only /api.php was up to date. I did not like that page being filled again as it is confusing now and bound to get out of date again as it is.
So to your question if we keep it if there is something better: hell no :D

In T359#1019615, @Spage wrote:

I'll revive the May 2014 revision.

I did so, generalizing some of the comments, mentioning new modules, and improving the links.

I did not like that page being filled again as it is confusing now and bound to get out of date again as it is.
So to your question if we keep it if there is something better: hell no :D

Yes, developers should definitely improve the generated API help.

It would be nice to get the best of both worlds with T89318: Replace on-wiki API documentation with Special:ApiHelp transclusion. Except... the wikibase API modules don't run on mw.org, nor does Wikibase client, and the transclusion will work across wikis. And there are issues with localization (T89768). Anyway after someone reviews the doc of wbxxx modules on that page for anything missing from the generated API help, we can kill it.

Any on-wiki examples that aren't in the generated API help should use Template:Api ex, e.g. {{Api ex | site=www.wikidata.org | p1=action=wbeditentity | p2=new=item | p3=data={} }}

Is there a good developer-level overview of claims, entities, Q-ids, and snaks somewhere?

Ok let's kill that page then ;-) Do you have time to see if there is anything useful to salvage?

Does this image help you? https://commons.wikimedia.org/wiki/File:Wikidata_statement.svg We have the Wikidata glossary at https://www.wikidata.org/wiki/Wikidata:Glossary but it currently is partially wrong. I will take some time to go through it.

Ok let's kill that page then ;-)

Hold on, I think we need an overview of using the Wikidata API modules and AFAIK I don't think api.php?action=help can generate one. Is https://www.mediawiki.org/wiki/Wikibase/API#General_introduction so terrible :) ?

BTW I see the directory Wikibase/docs/ has various documentation files. Publishing them is T48526: System documentation integrated in source code but it's in nobody's immediate plans. If you envision Wikibase source having an API overview that gets published, I'm supportive.

Do you have time to see if there is anything useful to salvage?

There is stuff worth salvaging, the wiki page has more information than the generated API help, I created subtask T89863: [Task] Merge on-wiki Wikibase/API documentation into Wikibase apihelp strings.. Someone familiar with the code should merge it.

If someone wants to Be Bold in the interim and kill the https://www.mediawiki.org/wiki/Wikibase/API#Modules section that's OK.

Does this image help you? https://commons.wikimedia.org/wiki/File:Wikidata_statement.svg We have the Wikidata glossary at https://www.wikidata.org/wiki/Wikidata:Glossary but it currently is partially wrong. I will take some time to go through it.

Thanks, they're both great! I'll mention them.

In T359#1081097, @Spage wrote:

What about commenting the T89863 plan in the Wikibase/API discussion page, with the intention of getting the editors of that page aware and involve in your efforts?

This task was part of ECT-March-2015, and it is still open and assigned. Assuming that it belongs to ECT-April-2015 as well. Otherwise please edit accordingly.

I'm an Outreachy18 intern and as part of T215682 / T198916 and with help from @srishakatux, I've made the following changes to Wikibase/API in my sandbox (https://www.mediawiki.org/wiki/User:Jeropbrenda/Sandbox/Wikibase/API):

  • Reformatted the page to follow API:Tutorial's format.
  • Reviewed every part of Wikibase/API to see if there is any information on the page that is missing from apihelp. I found that for all the modules, the parameters listed on-wiki are also in apihelp. In fact, apihelp has more parameters for most of the modules. As for the examples, most of the on-wiki examples are identical to the ones in apihelp, and some only differ by parameter values. One big difference is that some of the on-wiki examples use PHP. That said, and in line with comment #1047482, I have rewritten the on-wiki Modules section to only link each module to it's respective apihelp documentation.

I'd like some feedback as to whether any of the changes I made are inappropriate or if we can merge the changes to the page.

I like the changes. The page is much easier to follow now due to its shorter length, and also we no longer need to try and keep the same docs up to date in 2 places!

@Addshore Thanks for the feedback. I'll integrate the changes to the page in the main namespace.

(with recent documentation changes to the Wikibase page, I am closing this task)