Jump to content

Talk:Wikibase/API

About this board

Shisma (talkcontribs)

hi,

I am working on a tool that performs edits in wikidata. I'd like to add a tag to the performed edits identifying my application. How and where can I apply for that?

Addshore (talkcontribs)

So, if you are using OAUth for authentication for users using your tool, and you are making edit through the user accounts then this should be automatically done for you.

If you want to add other tags then I believe you'll need to wait for https://phabricator.wikimedia.org/T155109

Shisma (talkcontribs)

I am making edits through the user account and I was not able to use the tags parameter.

I'd like to apply for a token like wikidata-for-firefox

Reply to "how to apply for tags?"

No reference for errors

1
Lucamauri (talkcontribs)

In the "Possible errorrs" chapter it is written that the error for a given module are visible using action=paraminfo&modules=modulename, but this is not true.
By calling the paraminfo action, only parameters are shown. Can anyone point to the right action to get errors?

Thanks

Reply to "No reference for errors"

How to find incoming redirects?

1
This post was hidden by Brycehughes (history)

$serialization does not have the correct number of parts

2
Shisma (talkcontribs)

I'm trying to make a statement with a property that does not exist yet.

  let claim = {
   type: "statement",
   mainsnak: {
       snaktype: "value",
       property: 'P370',
       datavalue: {
         type: "string",
         value: 'foo',
       }
   },
   id: "Q4115189", // ← do I have to use a guid here? A guid of what?
   rank: "normal"
  }

but the answer is $serialization does not have the correct number of parts. What am I doing wrong? What is a part?

Addshore (talkcontribs)

Yes, the ID here is the GUID. Q4115189 doesn't have enough parts to be a GUID (a bit before and after a $).

You can use wbcreateclaim to create a statement without needing to create the JSON https://www.wikidata.org/w/api.php?action=help&modules=wbcreateclaim

If you want to use wbsetclaim then you have to create your own valid GUID locally before submitting.

Reply to "$serialization does not have the correct number of parts"
ԱշոտՏՆՂ (talkcontribs)

The possible values of wbeuaspect are S, L, D, T, C, X, O. I guess L is for Label, D is for Description, S is probability for sitelink or statement, what about the others?

Shirayuki (talkcontribs)
ԱշոտՏՆՂ (talkcontribs)

Thanks, Shirayuki ^_^

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

3
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

4
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:

{'claims':[
    {'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.

Example:

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.

Deserializers\\Exceptions\\MissingTypeException?

2
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",
   "snaktype":"value",
   "property":"p1",
   "datavalue":  {
     "value":"bot test",
     "type":"string"
   }
 }

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"

What does "snak" mean?

2
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