Page MenuHomePhabricator

Fetch information from the similar_users API
Open, Needs TriagePublic



In order to display information about similar editors, we need to be able to fetch information about them from the similar_users API.

We should work with interfaces and domain objects in order to make it easier to stub the similar_users API during development and testing on the Beta Cluster.

  • We have programatic access to the similar_users API, e.g.
use MediaWiki\Extension\SimilarEditors\SimilarUsersClient;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserIdentityValue;

$similarUsersBaseUrl = '...';
$target = new UserIdentityValue( 1234567890, 'Foo' );

$httpRequestFactory = MediaWikiServices::getInstance()->getHttpRequestFactory();
$client = new SimilarUsersClient( $httpRequestFactory, $similarUsersBaseUrl );
$result = $client->getSimilarUsers( $target );
  • The API returns domain objects, i.e. the signature of SimilarUsersClient::getSimilarUsers() above would be something like:
  * @param UserIdentity $target
  * @return SimilarUser[] The list of users similar to the target user
public function getSimilarUsers( UserIdentity $target ): array;
  • The base URL of the similar_users service is configurable
  1. The return type of the /v1/similarusers/ endpoint is documented (inline!) here:
  2. The high-level documentation of the service is here:
  3. In production, the base URLs of all services are available via $wgLocalServices, which is defined here: