I am trying to create a script in Wikidata that creates a claim for certain entities. The claim should have a property of "external identifier" and a value that is the identifier generated by an external organization. Additionally, I want the value to be a hyperlink that directs the user to the organization's page when clicked.
To clarify, I want the variable "objectIdentifier" to be displayed as text, but when clicked, it should redirect to "redirectURL", the organization's page. The identifier is an alphanumeric code, and I am currently unable to make it into a hyperlink using my current function.
Here is the function I am using to create the claim:
def writeStatement(apiUrl, editToken, subjectQNumber, propertyPNumber, objectIdentifier, redirectURL):
parameters = {
'action': 'wbcreateclaim',
'format': 'json',
'entity': subjectQNumber,
'snaktype': 'value',
'bot': '1',
'token': editToken,
'property': propertyPNumber,
'value': '"' + objectIdentifier + '"',
'url': redirectURL
}
r = session.post(apiUrl, data=parameters)
data = r.json()
return data
However, the function currently only writes the identifier as plain text without creating a hyperlink.
Setting a formatter URL on the property might be all that’s needed.