henryr
henryr

Reputation: 169

Create a claim on Wikidata with a specific type of value

I am trying to ingest data to a local Wikibase, which I installed following the steps described in https://docs.docker.com/compose/install/. I'm using the API of wikibase/wikidata for the ingestion and it works as expected. For instance, I could create the triple Q1, P1, "200" as explained here:

/api.php?action=wbcreateclaim&entity=Q1&property=P1&snaktype=value&value="200"

So, I need to specify the type of the value according to xsd, namely something as following

Q1 P1 "200"^^xsd:integer

I'm aware that we can specify the range of a property when we create it (see API) by the datavalue.type field (see documentation). However, in this case, the node always will be string and the type of that value is what I want to set (integer).

I know that it should be possible, just see one identifier (e.g., Q27036482 ) on Wikidata in turtle format. Next, one real example

v:67929068efe9dbc374bc4dc78d86121d a wikibase:TimeValue ;
    wikibase:timeValue "2015-09-23T00:00:00Z"^^xsd:dateTime ;
    wikibase:timePrecision "11"^^xsd:integer ;
    wikibase:timeTimezone "0"^^xsd:integer ;
    wikibase:timeCalendarModel <http://www.wikidata.org/entity/Q1985727> .

Can anyone give me a clue about that? Many thanks for considering my request.

Upvotes: 0

Views: 217

Answers (1)

Vanya Usalko
Vanya Usalko

Reputation: 433

I was struggling with the same issue when wrote the django-wikibase adapter. The time datatype defined in the wikibase documentation: https://doc.wikimedia.org/Wikibase/master/php/md_docs_topics_json.html

So in your case, without URL-encoding, the get request could look like this:

/api.php?action=wbcreateclaim&entity=Q1&property=P1&snaktype=value&value={"time":"+2022-01-19T00:00:00Z","timezone":0,"before": 0,"after":0,"precision":11,"calendarmodel":"http://www.wikidata.org/entity/Q1985727"}

Please be sure that property P1 in that case has a "time" data type. And pay attention to the format of the "time" field. Not all wikibase versions have the full support of ISO 8601.

Upvotes: 0

Related Questions