Reference

class wikibase_api.models.Reference(api)

Collection of API functions for references

Example function call:

from wikibase_api import Wikibase

wb = Wikibase(
    # Parameters
)

claim_id = "Q2$8C67587E-79D5-4E8C-972C-A3C5F7ED06B3"
r = wb.reference.add(claim_id, "P854", "https://example.com")
print(r)
add(claim_id, property_id, value, snak_type='value', index=None)

Create a new reference for the specified claim

Parameters:
  • claim_id (str) – Claim identifier (e.g. "Q2$8C67587E-79D5-4E8C-972C-A3C5F7ED06B3")
  • property_id (str) – Property identifier (e.g. "P1")
  • value (any) – Value of the reference. If snak_type is set to “novalue” or “somevalue”, value must be None
  • snak_type (str) – Value type (one of ["value", "novalue", "somevalue"]. "value" (default) is used for normal property-value pairs. "novalue" is used to indicate that an item has none of the property (e.g. a person has no children). "somevalue" is used when it is known that a value exists, but the value itself is not known
  • index (int) – Position of the new reference within the list of references (e.g. 0 to add the reference to the top of the list)
Returns:

Response

Return type:

dict

remove(claim_id, reference_ids)

Delete the specified reference(s)

Parameters:
  • claim_id (str) – Claim identifier (e.g. "Q2$8C67587E-79D5-4E8C-972C-A3C5F7ED06B3")
  • reference_ids (str or list(str)) – Hash(es) of the reference(s) to be deleted (e.g. "9d5f29a997ad9ced2b1138556a896734148c4a0c", ["9d5f29a997ad9ced2b1138556a896734148c4a0c", "0b0ca37729a3f637c100832d2a30fe9d867ef385"])
Returns:

Response

Return type:

dict

update(claim_id, property_id, reference_id, value, snak_type='value', index=None)

Update the value of the specified reference

Parameters:
  • claim_id (str) – Claim identifier (e.g. "Q2$8C67587E-79D5-4E8C-972C-A3C5F7ED06B3")
  • property_id (str) – Property identifier (e.g. "P1")
  • reference_id (str) – Hash of the reference to be updated (e.g. "9d5f29a997ad9ced2b1138556a896734148c4a0c")
  • value (any) – Value of the reference. If snak_type is set to “novalue” or “somevalue”, value must be None
  • snak_type (str) – Value type (one of ["value", "novalue", "somevalue"]. "value" (default) is used for normal property-value pairs. "novalue" is used to indicate that an item has none of the property (e.g. a person has no children). "somevalue" is used when it is known that a value exists, but the value itself is not known
  • index (int) – Position of the new reference within the list of references (e.g. 0 to add the reference to the top of the list)
Returns:

Response

Return type:

dict