Hi David,

 

Thanks a lot for your answer.

We can now obtain all required data like this: https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q78&format=json

The result contains the labels organised by language tags and geo data (P625) that we need as well. This is great!

 

I was also able to create a OAUTH 2.0 token (linked to my user).

 

What did not work, was token refreshing (https://www.wikidata.org/wiki/Wikidata:REST_API/Authentication#Non-owner-only_clients).

 

I tried this:

 

 curl --request POST \                                                                        

  --url https://www.wikidata.org/w/rest.php/w/rest.php/oauth2/access_token \

  --header 'Content-Type: application/x-www-form-urlencoded' \

  --data grant_type=client_credentials \

  --data client_id=abc \

  --data client_secret=xyz

 

I get the following response:

 

{"messageTranslations":{"en":"The requested relative path (/w/rest.php/oauth2/access_token) did not match any known handler"},"httpCode":404,"httpReason":"Not Found"}

 

Any idea what I am doing wrong?

 

Thanks again and kind regards,

 

Tobias

 

 

 

 

From: David Causse <dcausse@wikimedia.org>
Reply to: A public mailing list about Wikimedia Search and Discovery projects <discovery@lists.wikimedia.org>
Date: Tuesday, 5 September 2023 at 09:34
To: A public mailing list about Wikimedia Search and Discovery projects <discovery@lists.wikimedia.org>
Subject: [discovery] Re: Language Annotations With Linked Data Fragments

 

On Tue, Sep 5, 2023 at 8:10 AM Tobias Schweizer <tobias.schweizer@switch.ch> wrote:

Hi there,

 

Hi!

 

Is there a way to get all labels for a certain language without specifying the label string itself? I tried wildcards but it did not work.

 

Filtering by language is sadly not possible using the LDF endpoint as it would require a FILTER sparql clause.

Language not appearing in the LDF output is sadly a known limitation [0] of the current implementation.

Also note that SPARQL/LDF is not the only way to extract information out of wikidata, have you considered using the wikidata wbgetentities API [1]?

It can be used to extract labels in a certain language [2]. I suppose also that the upcoming wikidata REST api [3] will cover this use case as well.

 

David.

 

0: https://phabricator.wikimedia.org/T305983

1: https://www.wikidata.org/w/api.php?action=help&modules=wbgetentities

2: https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q42&props=labels&languages=en

3: https://doc.wikimedia.org/Wikibase/master/js/rest-api/