Hi Markus,
at [1] you can see the way we did it at our prototypical Wikidata D:SWARM importer.
0. We look up our cache, whether we already have retrieved this Property from the API previously (if not, then we continue with 1.; otherwise we simply return the cached Property) 1. We create a simple Property (Entity) with the help of the Property label 2. We do a create-or-edit request with this at 'wbeditentity' 3. We evaluate the response 3.1 If a new entity was created, we extract the Property identifier (and put it in our cache) 3.2 If we tried to (re-)create an already existing property, we try to parse the error message exactly for this pattern and extract the Property identifier from there (and put it in our cache)
To speed up the whole process, it might be useful to know all utilised properties in advance to safe the requests for Property identifiers at Entity creation time.
Cheers,
Bo/T
[1] https://github.com/zazi/wikidata-d-swarm-importer/blob/own_mediawiki_api_cli...
Quoting Markus Krötzsch markus@semantic-mediawiki.org:
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.
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 ;-)
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 ...
Thanks,
Markus
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech