Discuss API modules

From semantic-mediawiki.org
(Redirected from Help talk:API)
These discussions were held with LiquidThreads. Each post's history is on its old Thread page, which now redirects here (list).

Incomplete documentation

If there are two limiting conditions in the ask query, e.g. [[Modification date::+]] [[Revision id::>20000]] what should they look like in the conditions field of the AJAX query URL? Alexander Mashintalk 14:55, 24 October 2014 (UTC)

Already found out: in ask, space-separated enclosed in [[]], in askargs, |-separated without brackets. Alexander Mashintalk 15:10, 24 October 2014 (UTC)

askargs: units of measurement

How can I add needed unit of measurement to a printout in {{#askargs:}}? Also, how can I format a date there? Alexander Mashintalk 03:53, 11 November 2014 (UTC)

It's even worse. It seems that all export features {{#askargs:}}, {{#ask:}}, csv and json formats simply ignore # in printouts (only showing units of measurement in the "printrequests"). Alexander Mashintalk 09:03, 13 November 2014 (UTC)
So, I have to convert units of measurements in my client application again, although it could have ben done by SMW. The application should know the conversion rates etc.
But even that is made difficult. The required units (when shown at all) are not in the query.results [(label)].printouts objects but in the query.printrequests. Moreover, while query.results [(label)].printouts is an object, query.printrequests is an array, so I cannot just go there and get the unit, I have to traverse the array at least once to convert in to an object with the same indices as query.results [(label)].printouts. Why? Why? Why?
I have to parse JSON, which is supposed to be parsed already, in dozens of lines of code; just because there is no sane way to get quantities in needed units in the API, or at least, it is not documented. Alexander Mashintalk 10:01, 18 November 2014 (UTC)
I suspect you are right that the ask API does not support units. You should be able to use Special:Ask though. And enhancements to the ask API, or its documentation, are certainly welcome. Jeroen De Dauw (talk) 08:01, 24 December 2014 (UTC)
My task was to make a fully dynamic (not cached with the rest of the wikipage) semantic map. At first I used SMW API and had to process units of measurement in my JavaScript. Then I found a more universal and robust solution: I developed an extension that enables server- and client-side inclusions on wikipages (with api.php?action=parse). So, this issue is not so pressing to me now. However, I still think that there is a bug in the API, not its documentation. Alexander Mashintalk 02:43, 25 December 2014 (UTC)

Limit and offset not working?

SMW 2.0 MW 1.23.5

It seeps support for the parameters argument is gone? if you try &parameters=limit%3D10 the API responds with "Unrecognized parameter: 'parameters'", it doesn't support continue parameter either? Is there a new method for query continue with ask API as the documented methods do not work? Karl pietsch (talk) 05:01, 13 November 2014 (UTC)

The API works as expected and has not been changed. As example see [0, 1, 2]. `parameters=` only works in connection with `askargs` where instead an `ask` request is defined by [3].
[0] https://semantic-mediawiki.org/w/api.php?action=askargs&conditions=Modification%20date::%2B&printouts=Modification%20date&parameters=%7Csort%3DModification%20date%7Corder%3Ddesc%7Climit=2
[1] https://semantic-mediawiki.org/w/api.php?action=askargs&conditions=Modification%20date::%2B&printouts=Modification%20date&parameters=%7Csort%3DModification%20date%7Corder%3Ddesc%7Climit=5%7Coffset=2
[2] https://semantic-mediawiki.org/w/api.php?action=askargs&conditions=Modification%20date::%2B&printouts=Modification%20date&parameters=%7Csort%3DModification%20date%7Corder%3Ddesc
[3] https://semantic-mediawiki.org/w/api.php?action=ask&query=%7C%3FModification%20date%7Csort%3DModification%20date%7Corder%3Ddesc James Hong Kong (talk) 08:06, 13 November 2014 (UTC)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.