Help:Remote request

From semantic-mediawiki.org
(Redirected from Help:Remote request)
Remote request
Describes how to consolidate query results from remote sources
Keywords
Table of Contents

The remote request is a feature that was introduced with Semantic MediaWiki 3.0.0Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x. to make it easy to share and consolidate query results from remote sources.

Remote sources[edit]

The feature requires configuration parameter $smwgQuerySourcesSets another query back-end for Semantic MediaWiki to be set and expects the following entry schema for targets to be selectable as remote sources:

$smwgQuerySources = [
	'exampleorg' => [
		'\SMW\Query\RemoteRequest',
		'url' => 'https://example.org/w/index.php',
		'cache' => 3600
	]
];
  • The source name can be an arbitrary string. Above example identifies exampleorg as the source that points to the destination that is defined by the url parameter.
  • The cache parameter indicating the "time to live" in seconds ensures that requests to a remote destination are cached and avoid creating unnecessary requests to the source for the specified duration. In the above example it is set to 1 hour (60 x 60 = 3600 seconds).

Remote request[edit]

Once a list of sources is available, embedded queries as well as queries executed via special page "Ask"Provides an interface that assists users with creating and executing semantic queries will have access to the source parameter and can request a remote execution. For example:

{{#ask:
 [[Has number::+]]
 |?Has number
 |format=table
 |limit=20
 |source=mw-foo
}}
  • Queries fetched from a remote source will inform the user about the context of the execution and is controlled by option SMW_REMOTE_REQ_SHOW_NOTE to configuration parameter $smwgRemoteReqFeatures.
  • Paging of results is not supported but using the @deferred query marker and the @control query marker can enable (if supported by the format to change the limit/offset parameters dynamically after results have been retrieved from a source without the need to alter the query manually.
  • In cases where a remote source doesn't support a selected format, the default `broadtable` format is used instead.

Remote response[edit]

File:Smw-remote-source-not-supported.png
Not supported Semantic MediaWiki remote source (3.0.0+)

By default any public wiki using Semantic MediaWiki is able to respond to a remote request which can be disabled, if necessary but it should be noted that disabling has only an administrative blocking effect with any public wiki allowing access to the special page "Ask"Provides an interface that assists users with creating and executing semantic queries despite being disabled for a remote request.

Removing option MW_REMOTE_REQ_SEND_RESPONSE from configuration parameter $smwgRemoteReqFeatures will block requests via the "RemoteRequest".

See also[edit]

Configuration parameters
Implementation suggestion
  • How to fetch data from special page "Ask"Provides an interface that assists users with creating and executing semantic queries via cURL? (with code example)1

References

  1. ^  Semantic MediaWiki: GitHub issue gh:smw:3168