In this example we generate a list of endangered species form wikidata, and with a few lines of code convert them into a facet that can be used in the ContentMine-API and toolchain.

First we query wikidata for all species that have an IUCN-ID, and download the JSON.

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?wikidataID ?term ?termLabel
WHERE
{
?wikidataID wdt:P627 ?wd . # find entities that have a IUCN-ID
?wikidataID wdt:P105 wd:Q7432 .# ... and have taxon Rank of species
?wikidataID wdt:P225 ?term . # also return the scientific name of the taxon
#?taxon wdt:P1843 ?taxonCommonName # if we want common names, this significantly reduces matches from 78k to 17k, and is not consistent over languages
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY ?term

Download JSON, not Full JSON

With a few lines of Python we add a unique ID within the ContentMine-dictionaries, and output a slightly restructured JSON.