Hi!

> What is the correct API call to find a property by its label (in a given
> language)? As the label is unique, the function I am looking for would
> return 1 or 0 answers. I only found wbsearchentities, which might return
> any number of results since it also searches aliases.

I'm not sure there's a data structure that allows to do it without
search... Of course, using RDF/SPARQL it would be easy to query for
that, but that involves service outside wikidata API.

> The problem I am facing is rather simple: I want to program an example
> that shows how to edit Wikidata using Wikidata Toolkit. To do this, I
> need a valid property that I can use in statements. I want to work on
> test.wikidata.org, of course, so I don't know which properties exist. I
> can create my own, but I should only do this if I did not do this yet
> (else I will get a "failed-save" error, which contains an error message,
> but it does not seem safe to parse this string for finding the id I am
> looking for). I could also create new properties every time someone is
> running the example program ;-)

We faced similar problem writing integration tests for Wikidata Query
Service. We did this: create an item with unique enough name on
test.wikidata.org (we chose QueryTestItem plus additional suffixes) and
use wbsearchentities to look for it. See:

https://github.com/wikimedia/wikidata-query-rdf/blob/master/tools/src/main/java/org/wikidata/query/rdf/tool/wikibase/WikibaseRepository.java#L137
and e.g.
https://github.com/wikimedia/wikidata-query-rdf/blob/master/tools/src/test/java/org/wikidata/query/rdf/tool/wikibase/WikibaseRepositoryIntegrationTest.java#L91

Of course, that means every test/edit would be messing with the same
entity, so people could step on each other's toes if they work on
test.wikidata.org, but I understand this is the nature of the test site
anyway.

> Since I could use any property, it would also help me if I could
> retrieve a list of properties by type. All I need is some (any) string
> property ...

You could probably then load
https://test.wikidata.org/wiki/Special:ListProperties/string and just
extract one of them.

-- 
Stas Malyshev
[email protected]

_______________________________________________
Wikidata-tech mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-tech

Reply via email to