Jump to navigation Jump to search

About this board

Is there any API for searching for entities with the exact match of label/alias?

CXuesong (talkcontribs)
Matěj Suchánek (talkcontribs)
CXuesong (talkcontribs)

Okay. Thanks for your confirmation!

Reply to "Is there any API for searching for entities with the exact match of label/alias?"

Change values from one property to another on the same item

Jura1 (talkcontribs)

At d:Q3107406#P161, I like to retrieve all statements with d:Property:P161 and then add them with property d:Property:P5030. Once done, delete all P161. Ideally in just 1 or 2 edits, and 2 or 3 api requests. I could do 1200 edits with Quickstatements, but I'd rather not.

Matěj Suchánek (talkcontribs)

It's possible with a single API request via wbeditentity. The data= will look like:

    {'id': '<the id of the claim to remove>', 'remove': ''},
    {<data of the claim>},

<data of the claim> is JSON of each claim, where you have to replace all P161 to P5030 and remove 'id' key.


Jura1 (talkcontribs)

Thanks. I will give it a try. I got a test working: .

It would slightly easier if the api sandbox had a json input box (even with formatting).

Jura1 (talkcontribs)

found that too. Thanks it worked.

Users who edit animated films would probably like a tool that could do that to move all claims from cast to voice actor.


SixTwoEightBot (talkcontribs)

I'm trying to use wbsetclaim. However, I always get this error:

{"error":{"code":"internal_api_error_Deserializers\\Exceptions\\MissingTypeException","info":"[XAG4RQpAEDcAADvq7GUAAAAR] Caught exception of type Deserializers\\Exceptions\\MissingTypeException"},"servedby":"mw1290"}

My claim is:

   "id": "Q4115189$ffa51229-4877-3135-a2e2-a22fe9b7039d",
   "datavalue":  {
     "value":"bot test",

Valerio Bozzolan (talkcontribs)

Hello! AFAIK you are missing the DataType. Here you are an example:

"snaktype": "value",
"property": "P1",
"datavalue": {
    "value": "bot test",
    "type": "string"
 "datatype": "string"

Actually this is described in the Wikibase/DataModel/JSON#Snaks page but you can also look at existing claims with the wbgetentities API query.

Reply to "Deserializers\\Exceptions\\MissingTypeException?"
813gan (talkcontribs)

in example 'Set a label (will overwrite)' filed "data" has value invalid value.

It should be either '{"labels":{"no":{"language":"no","value":"Bar"}}}' or '{"labels":[{"language":"no","value":"Bar"}]}'

Reply to "bug in example"
CXuesong (talkcontribs)

Just out of my curiosity, what does the word "snak" mean in mainsnak? I met this word when trying to get claims from Wikibase API

"P3221": [
        "mainsnak": {
            "snaktype": "value",
            "property": "P3221",
            "hash": "983e9e5d4a43d9f321e1104fa31b23cbb52d772f",
            "datavalue": {
                "value": "destination/mount-everest",
                "type": "string"
            "datatype": "external-id"
        "type": "statement",
        "id": "Q513$7DFFB96C-0A8D-4024-97EA-23A1A77CAFD2",
        "rank": "normal"

Another question: will there be some other "snak"s that are not "mainsnak"? If not, can I treat claims and snaks as 1:1 pairs? Thanks.

Addshore (talkcontribs)
Reply to "What does "snak" mean?"
There are no older topics