Dataverse file id, retrieving the JSON-LD citation via API

15 views
Skip to first unread message

Raman Prasad

unread,
Apr 25, 2018, 11:56:40 AM4/25/18
to Dataverse Users Community
Hi,

If I have a Dataverse file ID, what's the best way to determine the DOI via API?

My goal is to retrieve the JSON-LD metadata for a file's dataset--but I may not know the DOI to start.

Thanks,

Raman

Philip Durbin

unread,
Apr 25, 2018, 12:50:01 PM4/25/18
to dataverse...@googlegroups.com
Hi Raman!

Huh, the awful hack I originally posted to https://groups.google.com/d/msg/dataverse-community/VG6gTMEd_Ps/-Ot6cWBnAwAJ isn't working anymore.

I wrote that on April 9th and I'm not sure if Harvard Dataverse was running 4.8.5 or if we had upgraded to 4.8.6 already. I'm not sure what changed.

Can you please open a GitHub issue about wanting to derive the DOI (or Handle) from a dataset based on a file id? It's in the citation from the Search API but as a URL and it sounds like you just want the DOI.

Here's an even worse hack that prints "The DOI for file id 3040230 is doi:10.7910/DVN/TJCLKP"

#!/bin/sh
# https://dataverse.harvard.edu/file.xhtml?fileId=3040230
FILEID=3040230
FILE_SEARCH=`curl -s https://dataverse.harvard.edu/api/search?q=entityId:$FILEID | jq .`
DOI_URL=`echo $FILE_SEARCH | jq '.data.items[0].dataset_citation' | grep -o 'https://doi.*' | cut -d, -f1`
DOI=`echo $DOI_URL | sed 's/https:\/\/doi/doi:/' | sed 's/\.org\///'`
echo "The DOI for file id $FILEID is $DOI"

I hope this helps,

Phil

--
You received this message because you are subscribed to the Google Groups "Dataverse Users Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-community+unsub...@googlegroups.com.
To post to this group, send email to dataverse-community@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dataverse-community/557877ac-d997-4f62-9de9-c5d954d63235%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Heppler, Michael

unread,
Apr 25, 2018, 1:15:11 PM4/25/18
to dataverse...@googlegroups.com
FYI, it looks like 4.8.6 went up to production and demo on April 4.

Hey, Raman!


On Wed, Apr 25, 2018 at 12:49 PM, Philip Durbin <philip...@harvard.edu> wrote:
Hi Raman!

Huh, the awful hack I originally posted to https://groups.google.com/d/msg/dataverse-community/VG6gTMEd_Ps/-Ot6cWBnAwAJ isn't working anymore.

I wrote that on April 9th and I'm not sure if Harvard Dataverse was running 4.8.5 or if we had upgraded to 4.8.6 already. I'm not sure what changed.

Can you please open a GitHub issue about wanting to derive the DOI (or Handle) from a dataset based on a file id? It's in the citation from the Search API but as a URL and it sounds like you just want the DOI.

Here's an even worse hack that prints "The DOI for file id 3040230 is doi:10.7910/DVN/TJCLKP"

#!/bin/sh
# https://dataverse.harvard.edu/file.xhtml?fileId=3040230
FILEID=3040230
FILE_SEARCH=`curl -s https://dataverse.harvard.edu/api/search?q=entityId:$FILEID | jq .`
DOI_URL=`echo $FILE_SEARCH | jq '.data.items[0].dataset_citation' | grep -o 'https://doi.*' | cut -d, -f1`
DOI=`echo $DOI_URL | sed 's/https:\/\/doi/doi:/' | sed 's/\.org\///'`
echo "The DOI for file id $FILEID is $DOI"

I hope this helps,

Phil
On Wed, Apr 25, 2018 at 11:56 AM, Raman Prasad <pra...@g.harvard.edu> wrote:
Hi,

If I have a Dataverse file ID, what's the best way to determine the DOI via API?

My goal is to retrieve the JSON-LD metadata for a file's dataset--but I may not know the DOI to start.

Thanks,

Raman

--
You received this message because you are subscribed to the Google Groups "Dataverse Users Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-community+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Dataverse Users Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-community+unsub...@googlegroups.com.
To post to this group, send email to dataverse-community@googlegroups.com.

Raman Prasad

unread,
Apr 25, 2018, 1:18:43 PM4/25/18
to Dataverse Users Community
Thanks, Phil!  The "worse" hack will definitely work.

I'll also open an issue.


On Wednesday, April 25, 2018 at 12:50:01 PM UTC-4, Philip Durbin wrote:
Hi Raman!

Huh, the awful hack I originally posted to https://groups.google.com/d/msg/dataverse-community/VG6gTMEd_Ps/-Ot6cWBnAwAJ isn't working anymore.

I wrote that on April 9th and I'm not sure if Harvard Dataverse was running 4.8.5 or if we had upgraded to 4.8.6 already. I'm not sure what changed.

Can you please open a GitHub issue about wanting to derive the DOI (or Handle) from a dataset based on a file id? It's in the citation from the Search API but as a URL and it sounds like you just want the DOI.

Here's an even worse hack that prints "The DOI for file id 3040230 is doi:10.7910/DVN/TJCLKP"

#!/bin/sh
# https://dataverse.harvard.edu/file.xhtml?fileId=3040230
FILEID=3040230
FILE_SEARCH=`curl -s https://dataverse.harvard.edu/api/search?q=entityId:$FILEID | jq .`
DOI_URL=`echo $FILE_SEARCH | jq '.data.items[0].dataset_citation' | grep -o 'https://doi.*' | cut -d, -f1`
DOI=`echo $DOI_URL | sed 's/https:\/\/doi/doi:/' | sed 's/\.org\///'`
echo "The DOI for file id $FILEID is $DOI"

I hope this helps,

Phil
On Wed, Apr 25, 2018 at 11:56 AM, Raman Prasad <pra...@g.harvard.edu> wrote:
Hi,

If I have a Dataverse file ID, what's the best way to determine the DOI via API?

My goal is to retrieve the JSON-LD metadata for a file's dataset--but I may not know the DOI to start.

Thanks,

Raman

--
You received this message because you are subscribed to the Google Groups "Dataverse Users Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-community+unsub...@googlegroups.com.
To post to this group, send email to dataverse...@googlegroups.com.

Philip Durbin

unread,
Apr 25, 2018, 1:22:44 PM4/25/18
to dataverse...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-community+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Dataverse Users Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-community+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages