It’s Friday afternoon, so why not write a DOI-to-JSON-LD resolver I thought?
Luckily, web services already exist to help me on this:
http://dx.doi.org/ – The global DOI service (that has a REST API yay!)
http://rdf-translator.appspot.com/ – An RDF translator (that has a REST API yay!)
So, putting these together with a bit of curl, you get:
#!/bin/bash DOI=$1 OUT=$2 curl -D - -L -H "Accept: application/rdf+xml" "http://dx.doi.org/$1" -o $2.rdf.xml curl --data-urlencode content@$2.rdf.xml http://rdf-translator.appspot.com/convert/detect/json-ld/content -o $2.json
The script takes 2 parameters – firstly the DOI itself, and secondly the output filename (no extensions, just the name!).
NB: thanks to @rmounce for the heads-up about DOI complexities. Put the DOI in double quotes, and bash will be happy.
So for example:
./doi-resolve-to-jsonld.sh "10.1126/science.1249721" choulet
Gives us 2 files:
The first being the RDF XML output from the DOI resolver, and the second being the converted JSON-LD: