Skip to content

Instantly share code, notes, and snippets.

@datadavev
Last active July 19, 2023 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save datadavev/f2d3233d852a1454af2a2fbd3e115cf2 to your computer and use it in GitHub Desktop.
Save datadavev/f2d3233d852a1454af2a2fbd3e115cf2 to your computer and use it in GitHub Desktop.
Referencing RDF with DOIs?

Find some RDF datasets in DataCite:

$ curl 'https://api.datacite.org/dois?query=formats:application%2Frdf%2Bxml' \
  | jq '{"id":.data[].id, "formats":.data[].attributes.formats}'
  
{
  "id": "10.18434/t4/1435037",
  "formats": [
    "application/rdf+xml",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  ]
}
{
  "id": "10.18434/t4/1435037",
  "formats": [
    "application/rdf+xml"
  ]
}
{
  "id": "10.18434/t4/1435037",
  "formats": [
    ".xml",
    "application/zip",
    "application/json",
    "application/rdf+xml",
    "130.85 MB"
  ]
}
{
  "id": "10.18434/t4/1435037",
  "formats": [
    "application/rdf+xml",
    "application/ld+json",
    "text/turtle"
  ]
}
...

Get the content for 10.18434/t4/1435037 using default accept (accept: */*):

$ curl 'https://doi.org/10.18434/t4/1435037'

...
< location: https://data.nist.gov/od/id/67C783D4BA814C8EE05324570681708A1899
...
curl 'https://data.nist.gov/od/id/67C783D4BA814C8EE05324570681708A1899'
{
  "@context": [
    "https://data.nist.gov/od/dm/nerdm-pub-context.jsonld",
    {
      "@base": "ark:/88434/mds107pcw08s"
    }
  ],
  "_schema": "https://data.nist.gov/od/dm/nerdm-schema/v0.7#",
  "_extensionSchemas": [
    "https://data.nist.gov/od/dm/nerdm-schema/pub/v0.7#/definitions/PublicDataResource"
  ],
  "@type": [
    "nrdp:DataPublication",
    "nrdp:PublicDataResource",
    "dcat:Dataset"
  ],
  "@id": "ark:/88434/mds107pcw08s",
  "doi": "doi:10.18434/T4/1435037",
  ...

Now request with accept application/xml+rdf:

curl -v -H "Accept: application/rdf+xml"  'https://doi.org/10.18434/t4/1435037'

...
< location: https://data.crosscite.org/10.18434%2Ft4%2F1435037
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment