As a developer using the Wikibase Action API, I want to be able to easily access best-rank statements, in order to follow the same logic as SPARQL queries (wdt:) or Lua modules (getBestStatements()).
Problem:
The wbgetclaims action has a rank parameter, but it only lets you filter by preferred, normal, or deprecated rank. If you want to use best-rank statements (i.e. preferred-rank if any, else normal-rank, never deprecated-rank), you have to implement that logic yourself, at the risk of getting it wrong; this also requires getting the statements for all ranks, or potentially making two network requests (first with rank=preferred, then with rank=normal), adding some network overhead either way. (For certain properties, it’s not uncommon to have tons of non-best-rank statements.)
Example:
Screenshots/mockups:
BDD
GIVEN an Item with some preferred-rank, normal-rank and deprecated-rank Statements for the same Property
WHEN I call wbgetclaims with the given Item ID, Property ID, and rank=best
THEN only the preferred-rank Statements are returned
GIVEN an Item with some normal-rank and deprecated-rank Statements for the same Property
WHEN I call wbgetclaims with the given Item ID, Property ID, and rank=best
THEN only the normal-rank Statements are returned
GIVEN an Item with some deprecated-rank Statements for the same Property
WHEN I call wbgetclaims with the given Item ID, Property ID, and rank=best
THEN no Statements are returned
Acceptance criteria:
- the wbgetclaims rank parameter accepts a fourth value, best, which causes the API to only return best-rank statements
- the documentation of the API parameter values makes it clear that unlike preferred/normal/deprecated, this is not a rank that an individual statement can have
- (nevertheless, I think adding this to the rank parameter makes more sense than having it as a separate parameter, because it can’t be meaningfully combined with any other rank value)
Open questions: