Search for "foo:P123" where "foo" is a known repository should be possible using Api\SearchEntities. Changes in T153793 allowed to search foreign entity's label etc but search using ID should be also possible.