Content types

Python
API
Published

October 10, 2023

Modified

July 17, 2025

Get DOI metadata

DOI API access

I was interested in getting the metadata for a DOI without using a package in Python or R. My goal was to get a better understanding of the APIs that are available to access DOI metadata.

Here is an example with a request for my first peer-reviewed publication.

import requests

doi_url = "https://doi.org/10.1177/1465116507076430"

headers = {"accept": "text/x-bibliography"}
r = requests.get(doi_url, headers=headers)

r.text
'Döring, H. (2007). The Composition of the College of Commissioners. European Union Politics, 8(2), 207â\x80\x93228. https://doi.org/10.1177/1465116507076430\n'

This is the API information I was interested in.

https://citation.crosscite.org/docs.html#sec-4

“Currently three DOI registration agencies have implemented content negotation for their DOIs: Crossref, DataCite and mEDRA. They support a number of metadata content types, some of which are common to the three RAs.”

I try to avoid xml-based formats, so that the following content types are of interst to me.

  • Formatted text citation // text/x-bibliography
  • BibTeX // application/x-bibtex
  • Citeproc JSON // application/vnd.citationstyles.csl+json
  • Schema.org in JSON-LD // application/vnd.schemaorg.ld+json (only DataCite)

It is actually nice to put a request into a function. I start with a simple example.

def get_doi_bib(doi):
    """Return a bibliography for a given DOI."""

    url = f"https://doi.org/{doi}"

    headers = {"accept": "text/x-bibliography"}
    r = requests.get(url, headers=headers)

    return r.text


get_doi_bib("10.1177/0958928715573481")
'Döring, H., & Schwander, H. (2015). Revisiting the left cabinet share: How to measure the partisan profile of governments in welfare state research. Journal of European Social Policy, 25(2), 175â\x80\x93193. https://doi.org/10.1177/0958928715573481\n'

To get the different formats I am interested in, I can rewrite the function.

import time
import requests

CONTENT_TYPES = {
    "bibliography": "text/x-bibliography",
    "bibtex": "application/x-bibtex",
    "json-csl": "application/vnd.citationstyles.csl+json",
    "json-ld": "application/vnd.schemaorg.ld+json",
}


def get_doi_data(doi, content_type="bibliography"):
    """Return metadata for DOI."""

    url = f"https://doi.org/{doi}"
    headers = {"accept": CONTENT_TYPES.get(content_type, "bibliography")}

    return requests.get(url, headers=headers)


doi = "10.1016/j.electstud.2016.07.002"

for key in CONTENT_TYPES:
    time.sleep(2)  # pause to avoid requests limit
    doi_request = get_doi_data(doi, key)
    print(f"DOI content type: {key}\n{doi_request.text}\n")
DOI content type: bibliography
Döring, H. (2016). Mapping established democracies: Integrated data on parties, elections and cabinets. Electoral Studies, 44, 535–543. https://doi.org/10.1016/j.electstud.2016.07.002


DOI content type: bibtex
 @article{D_ring_2016, title={Mapping established democracies: Integrated data on parties, elections and cabinets}, volume={44}, ISSN={0261-3794}, url={http://dx.doi.org/10.1016/j.electstud.2016.07.002}, DOI={10.1016/j.electstud.2016.07.002}, journal={Electoral Studies}, publisher={Elsevier BV}, author={Döring, Holger}, year={2016}, month=dec, pages={535–543} }


DOI content type: json-csl
{"indexed":{"date-parts":[[2025,7,16]],"date-time":"2025-07-16T12:16:04Z","timestamp":1752668164004},"reference-count":43,"publisher":"Elsevier BV","license":[{"start":{"date-parts":[[2016,12,1]],"date-time":"2016-12-01T00:00:00Z","timestamp":1480550400000},"content-version":"tdm","delay-in-days":0,"URL":"https:\/\/www.elsevier.com\/tdm\/userlicense\/1.0\/"}],"content-domain":{"domain":["elsevier.com","sciencedirect.com"],"crossmark-restriction":true},"published-print":{"date-parts":[[2016,12]]},"DOI":"10.1016\/j.electstud.2016.07.002","type":"journal-article","created":{"date-parts":[[2016,7,23]],"date-time":"2016-07-23T05:27:36Z","timestamp":1469251656000},"page":"535-543","update-policy":"http:\/\/dx.doi.org\/10.1016\/elsevier_cm_policy","source":"Crossref","is-referenced-by-count":5,"special_numbering":"C","title":"Mapping established democracies: Integrated data on parties, elections and cabinets","prefix":"10.1016","volume":"44","author":[{"given":"Holger","family":"D\u00f6ring","sequence":"first","affiliation":[]}],"member":"78","reference":[{"key":"10.1016\/j.electstud.2016.07.002_bib1","series-title":"The European Representative Democracy Data Archive, Release 3","author":"Andersson","year":"2014"},{"key":"10.1016\/j.electstud.2016.07.002_bib2","series-title":"Comparative Political Data Set 1960\u20132013","author":"Armingeon","year":"2015"},{"key":"10.1016\/j.electstud.2016.07.002_bib3","doi-asserted-by":"crossref","first-page":"143","DOI":"10.1177\/1354068812462931","article-title":"Measuring party positions in Europe: the Chapel Hill expert survey trend file, 1999\u20132010","volume":"21","author":"Bakker","year":"2015","journal-title":"Party Politics"},{"key":"10.1016\/j.electstud.2016.07.002_bib4","doi-asserted-by":"crossref","first-page":"303","DOI":"10.1177\/1354068810369148","article-title":"Out with the old, in with the \u201cnew\u201d: what constitutes a new party?","volume":"17","author":"Barnea","year":"2011","journal-title":"Party Politics"},{"key":"10.1016\/j.electstud.2016.07.002_bib5","series-title":"Party Policy in Modern Democracies","author":"Benoit","year":"2006"},{"key":"10.1016\/j.electstud.2016.07.002_bib6","doi-asserted-by":"crossref","first-page":"1523","DOI":"10.1177\/0010414012463905","article-title":"A\u00a0complete data set of political regimes, 1800\u20132007","volume":"46","author":"Boix","year":"2013","journal-title":"Comp. Political Stud."},{"key":"10.1016\/j.electstud.2016.07.002_bib7","doi-asserted-by":"crossref","first-page":"360","DOI":"10.1016\/j.electstud.2013.01.005","article-title":"Democratic electoral systems around the world, 1946\u20132011","volume":"32","author":"Bormann","year":"2013","journal-title":"Elect. Stud."},{"key":"10.1016\/j.electstud.2016.07.002_bib8","series-title":"Das parlamentarische Wahlrecht: Ein Handbuch \u00fcber die Bildung der gesetzgebenden K\u00f6rperschaften in Europa \u2013 2. Band: Allgemeiner Teil","author":"Braunias","year":"1932"},{"key":"10.1016\/j.electstud.2016.07.002_bib9","series-title":"Parties and Democracy: Coalition Formation and Government Functioning in Twenty States","author":"Budge","year":"1993"},{"key":"10.1016\/j.electstud.2016.07.002_bib10","series-title":"Mapping Policy Preferences: Estimates for Parties, Electors, and Governments, 1945-1998","author":"Budge","year":"2001"},{"key":"10.1016\/j.electstud.2016.07.002_bib11","series-title":"Political Parties of Eastern Europe: a Guide to Politics in the Post-communist Era","author":"Bugajski","year":"2002"},{"key":"10.1016\/j.electstud.2016.07.002_bib12","doi-asserted-by":"crossref","first-page":"73","DOI":"10.1111\/j.1475-6765.1984.tb00080.x","article-title":"Left right political scales: some expert judgments","volume":"12","author":"Castles","year":"1984","journal-title":"Eur. J. Political Res."},{"key":"10.1016\/j.electstud.2016.07.002_bib13","doi-asserted-by":"crossref","first-page":"119","DOI":"10.1111\/j.1475-6765.2009.01888.x","article-title":"Measuring government duration and stability in Central Eastern European democracies","volume":"49","author":"Conrad","year":"2010","journal-title":"Eur. J. Political Res."},{"key":"10.1016\/j.electstud.2016.07.002_bib14","doi-asserted-by":"crossref","first-page":"193","DOI":"10.1111\/j.1467-9477.1994.tb00144.x","article-title":"Termination of Danish government coalitions: theoretical and empirical aspects","volume":"17","author":"Damgaard","year":"1994","journal-title":"Scand. Political Stud."},{"key":"10.1016\/j.electstud.2016.07.002_bib15","doi-asserted-by":"crossref","first-page":"161","DOI":"10.1177\/1465116512461189","article-title":"The collective action of data collection: a data infrastructure on parties, elections and cabinets","volume":"14","author":"D\u00f6ring","year":"2013","journal-title":"Eur. Union Politics"},{"key":"10.1016\/j.electstud.2016.07.002_bib16","first-page":"17","article-title":"ParlGov: a new data infrastructure in comparative politics","volume":"23","author":"D\u00f6ring","year":"2013","journal-title":"APSA Comp. Politics Newsl."},{"key":"10.1016\/j.electstud.2016.07.002_bib17","first-page":"19","article-title":"A\u00a0user-driven and flexible procedure for data linking","volume":"2010","author":"Ejik","year":"2010","journal-title":"IASSIST Q."},{"key":"10.1016\/j.electstud.2016.07.002_bib18","doi-asserted-by":"crossref","first-page":"495","DOI":"10.1111\/j.1468-2508.2007.00546.x","article-title":"Punishment or protest? understanding European Parliament elections","volume":"69","author":"Hix","year":"2007","journal-title":"J.\u00a0Politics"},{"key":"10.1016\/j.electstud.2016.07.002_bib19","doi-asserted-by":"crossref","first-page":"965","DOI":"10.1177\/001041402236310","article-title":"Does left\/right structure party positions on European integration?","volume":"35","author":"Hooghe","year":"2002","journal-title":"Comp. Political Stud."},{"key":"10.1016\/j.electstud.2016.07.002_bib20","doi-asserted-by":"crossref","first-page":"73","DOI":"10.1177\/1354068895001001004","article-title":"Expert interpretations of party space and party locations in 42 societies","volume":"1","author":"Huber","year":"1995","journal-title":"Party Politics"},{"key":"10.1016\/j.electstud.2016.07.002_bib21","doi-asserted-by":"crossref","first-page":"381","DOI":"10.1111\/1475-6765.12030","article-title":"Determinants of cabinet size","volume":"53","author":"Indridason","year":"2014","journal-title":"Eur. J. Political Res."},{"key":"10.1016\/j.electstud.2016.07.002_bib22","series-title":"Western European Political Parties: a Comprehensive Guide","year":"1989"},{"key":"10.1016\/j.electstud.2016.07.002_bib23","series-title":"Mapping Policy Preferences II: Estimates for Parties, Electors and Governments in Central and Eastern Europe, European Union and OECD 1990-2003","author":"Klingemann","year":"2006"},{"key":"10.1016\/j.electstud.2016.07.002_bib24","series-title":"Policy and Party Competition","author":"Laver","year":"1992"},{"key":"10.1016\/j.electstud.2016.07.002_bib25","series-title":"The International Almanac of Electoral History","author":"Mackie","year":"1991"},{"key":"10.1016\/j.electstud.2016.07.002_bib26","doi-asserted-by":"crossref","first-page":"211","DOI":"10.1146\/annurev.polisci.1.1.211","article-title":"The party family and its study","volume":"1","author":"Mair","year":"1998","journal-title":"Annu. Rev. Political Sci."},{"key":"10.1016\/j.electstud.2016.07.002_bib27","doi-asserted-by":"crossref","first-page":"654","DOI":"10.1111\/1475-6765.12054","article-title":"Defining and classifying technocrat-led and technocratic governments","volume":"53","author":"McDonnell","year":"2014","journal-title":"Eur. J. Political Res."},{"key":"10.1016\/j.electstud.2016.07.002_bib28","series-title":"Political Parties of Europe","year":"1983"},{"key":"10.1016\/j.electstud.2016.07.002_bib29","series-title":"Coalition Governments in Western Europe","year":"2000"},{"key":"10.1016\/j.electstud.2016.07.002_bib30","doi-asserted-by":"crossref","first-page":"869","DOI":"10.1111\/j.0304-4130.2004.00178.x","article-title":"Party government in Central Eastern European democracies: a data collection (1990-2003)","volume":"43","author":"M\u00fcller-Rommel","year":"2004","journal-title":"Eur. J. Political Res."},{"key":"10.1016\/j.electstud.2016.07.002_bib31","series-title":"Elections in Europe: a Data Handbook","year":"2010"},{"key":"10.1016\/j.electstud.2016.07.002_bib32","doi-asserted-by":"crossref","first-page":"283","DOI":"10.1111\/1475-6765.00471","article-title":"Measuring party orientations towards European integration: results from an expert survey","volume":"36","author":"Ray","year":"1999","journal-title":"Eur. J. Political Res."},{"key":"10.1016\/j.electstud.2016.07.002_bib33","series-title":"International Guide to Electoral Statistics; Guide International Des Statistiques \u00c9lectorales","first-page":"1","article-title":"Introduction","author":"Rokkan","year":"1969"},{"key":"10.1016\/j.electstud.2016.07.002_bib34","series-title":"International guide to electoral statistics; Guide international des statistiques \u00e9lectorales","year":"1969"},{"key":"10.1016\/j.electstud.2016.07.002_bib35","series-title":"Elections and Parties in New European Democracies","author":"Rose","year":"2003"},{"key":"10.1016\/j.electstud.2016.07.002_bib36","doi-asserted-by":"crossref","first-page":"270","DOI":"10.1016\/j.electstud.2013.10.001","article-title":"Updating the party government data set","volume":"34","author":"Seki","year":"2014","journal-title":"Elect. Stud."},{"key":"10.1016\/j.electstud.2016.07.002_bib37","doi-asserted-by":"crossref","first-page":"391","DOI":"10.1111\/j.1475-6765.2005.00232.x","article-title":"How unstable? Volatility and the genuinely new parties in Eastern Europe","volume":"44","author":"Sikk","year":"2005","journal-title":"Eur. J. Political Res."},{"key":"10.1016\/j.electstud.2016.07.002_bib38","series-title":"Die Wahl der Parlamente und anderer Staatsorgane","year":"1969"},{"key":"10.1016\/j.electstud.2016.07.002_bib39","doi-asserted-by":"crossref","first-page":"261","DOI":"10.1111\/1475-6765.00513","article-title":"Delegation and accountability in parliamentary democracies","volume":"37","author":"Str\u00f8m","year":"2000","journal-title":"Eur. J. Political Res."},{"key":"10.1016\/j.electstud.2016.07.002_bib40","series-title":"Veto Players: How Political Institutions Work","author":"Tsebelis","year":"2002"},{"key":"10.1016\/j.electstud.2016.07.002_bib41","doi-asserted-by":"crossref","first-page":"187","DOI":"10.1017\/S0007123411000263","article-title":"Constitutionalizing party democracy: the constitutive codification of political parties in post-war Europe","volume":"42","author":"Van Biezen","year":"2012","journal-title":"Br. J. Political Sci."},{"key":"10.1016\/j.electstud.2016.07.002_bib42","series-title":"Mapping Policy Preferences from Texts III: Statistical Solutions for Manifesto Analysts","author":"Volkens","year":"2013"},{"key":"10.1016\/j.electstud.2016.07.002_bib43","series-title":"Party Government in 48 Democracies (1945-1998): Composition, Duration, Personnel","author":"Woldendorp","year":"2000"}],"container-title":"Electoral Studies","original-title":[],"language":"en","link":[{"URL":"https:\/\/api.elsevier.com\/content\/article\/PII:S0261379416301652?httpAccept=text\/xml","content-type":"text\/xml","content-version":"vor","intended-application":"text-mining"},{"URL":"https:\/\/api.elsevier.com\/content\/article\/PII:S0261379416301652?httpAccept=text\/plain","content-type":"text\/plain","content-version":"vor","intended-application":"text-mining"}],"deposited":{"date-parts":[[2018,7,17]],"date-time":"2018-07-17T21:43:09Z","timestamp":1531863789000},"score":1,"resource":{"primary":{"URL":"https:\/\/linkinghub.elsevier.com\/retrieve\/pii\/S0261379416301652"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2016,12]]},"references-count":43,"alternative-id":["S0261379416301652"],"URL":"http:\/\/dx.doi.org\/10.1016\/j.electstud.2016.07.002","relation":{},"ISSN":["0261-3794"],"subject":[],"container-title-short":"Electoral Studies","published":{"date-parts":[[2016,12]]},"assertion":[{"value":"Elsevier","name":"publisher","label":"This article is maintained by"},{"value":"Mapping established democracies: Integrated data on parties, elections and cabinets","name":"articletitle","label":"Article Title"},{"value":"Electoral Studies","name":"journaltitle","label":"Journal Title"},{"value":"https:\/\/doi.org\/10.1016\/j.electstud.2016.07.002","name":"articlelink","label":"CrossRef DOI link to publisher maintained version"},{"value":"article","name":"content_type","label":"Content Type"},{"value":"\u00a9 2016 Elsevier Ltd. All rights reserved.","name":"copyright","label":"Copyright"}]}

DOI content type: json-ld
No acceptable resource available.

Linked data json-ld

json-ld is only available for content registered with DataCite.

A DOI for an article does not return json-ld metadata.

doi_content = get_doi_data(doi, "json-ld")

doi_content
<Response [406]>
doi_content.text
'No acceptable resource available.'

A DOI for a dataset returns json-ld metadata.

doi_content = get_doi_data("10.7910/DVN/BUWAAF", "json-ld")

doi_content
<Response [200]>
doi_content.text
'{\n  "@context": "http://schema.org",\n  "@type": "Dataset",\n  "@id": "https://doi.org/10.7910/dvn/buwaaf",\n  "url": "https://dataverse.harvard.edu/citation?persistentId=doi:10.7910/DVN/BUWAAF",\n  "name": "Party Facts – Version 2022",\n  "author": [\n    {\n      "name": "Paul Bederke",\n      "givenName": "Paul",\n      "familyName": "Bederke",\n      "affiliation": {\n        "@type": "Organization",\n        "name": "University of Konstanz"\n      },\n      "@type": "Person",\n      "@id": "https://orcid.org/0000-0001-7555-8656"\n    },\n    {\n      "name": "Holger Döring",\n      "givenName": "Holger",\n      "familyName": "Döring",\n      "affiliation": {\n        "@type": "Organization",\n        "name": "GESIS – Leibniz Institute for the Social Sciences"\n      },\n      "@type": "Person",\n      "@id": "https://orcid.org/0000-0002-6616-8805"\n    },\n    {\n      "name": "Sven Regel",\n      "givenName": "Sven",\n      "familyName": "Regel",\n      "affiliation": {\n        "@type": "Organization",\n        "name": "WZB Berlin Social Science Center"\n      },\n      "@type": "Person"\n    }\n  ],\n  "editor": {\n    "name": "Paul Bederke",\n    "givenName": "Paul",\n    "familyName": "Bederke",\n    "affiliation": {\n      "@type": "Organization",\n      "name": "University of Konstanz"\n    },\n    "contributorType": "ContactPerson",\n    "@type": "Person"\n  },\n  "description": "Party Facts links datasets on political parties",\n  "license": [\n    "info:eu-repo/semantics/openAccess",\n    "https://creativecommons.org/publicdomain/zero/1.0/legalcode"\n  ],\n  "version": "1.0",\n  "keywords": "Social Sciences",\n  "contentSize": [\n    "8063454",\n    "1430994",\n    "1619721",\n    "21778",\n    "9673",\n    "8747276"\n  ],\n  "encodingFormat": [\n    "application/zip",\n    "text/html",\n    "text/tab-separated-values",\n    "text/tab-separated-values",\n    "text/tab-separated-values",\n    "text/csv"\n  ],\n  "datePublished": "2022",\n  "dateModified": "2022-12-16",\n  "@reverse": {\n    "isBasedOn": {\n      "@id": "https://doi.org/10.1177/1354068818820671",\n      "@type": "ScholarlyArticle"\n    }\n  },\n  "schemaVersion": "http://datacite.org/schema/kernel-4",\n  "publisher": {\n    "@type": "Organization",\n    "name": "Harvard Dataverse"\n  },\n  "provider": {\n    "@type": "Organization",\n    "name": "datacite"\n  }\n}'
doi_content.json()
{'@context': 'http://schema.org',
 '@type': 'Dataset',
 '@id': 'https://doi.org/10.7910/dvn/buwaaf',
 'url': 'https://dataverse.harvard.edu/citation?persistentId=doi:10.7910/DVN/BUWAAF',
 'name': 'Party Facts – Version 2022',
 'author': [{'name': 'Paul Bederke',
   'givenName': 'Paul',
   'familyName': 'Bederke',
   'affiliation': {'@type': 'Organization', 'name': 'University of Konstanz'},
   '@type': 'Person',
   '@id': 'https://orcid.org/0000-0001-7555-8656'},
  {'name': 'Holger Döring',
   'givenName': 'Holger',
   'familyName': 'Döring',
   'affiliation': {'@type': 'Organization',
    'name': 'GESIS – Leibniz Institute for the Social Sciences'},
   '@type': 'Person',
   '@id': 'https://orcid.org/0000-0002-6616-8805'},
  {'name': 'Sven Regel',
   'givenName': 'Sven',
   'familyName': 'Regel',
   'affiliation': {'@type': 'Organization',
    'name': 'WZB Berlin Social Science Center'},
   '@type': 'Person'}],
 'editor': {'name': 'Paul Bederke',
  'givenName': 'Paul',
  'familyName': 'Bederke',
  'affiliation': {'@type': 'Organization', 'name': 'University of Konstanz'},
  'contributorType': 'ContactPerson',
  '@type': 'Person'},
 'description': 'Party Facts links datasets on political parties',
 'license': ['info:eu-repo/semantics/openAccess',
  'https://creativecommons.org/publicdomain/zero/1.0/legalcode'],
 'version': '1.0',
 'keywords': 'Social Sciences',
 'contentSize': ['8063454', '1430994', '1619721', '21778', '9673', '8747276'],
 'encodingFormat': ['application/zip',
  'text/html',
  'text/tab-separated-values',
  'text/tab-separated-values',
  'text/tab-separated-values',
  'text/csv'],
 'datePublished': '2022',
 'dateModified': '2022-12-16',
 '@reverse': {'isBasedOn': {'@id': 'https://doi.org/10.1177/1354068818820671',
   '@type': 'ScholarlyArticle'}},
 'schemaVersion': 'http://datacite.org/schema/kernel-4',
 'publisher': {'@type': 'Organization', 'name': 'Harvard Dataverse'},
 'provider': {'@type': 'Organization', 'name': 'datacite'}}

Redirects

Finally, I was interested if there is a redirect to a DOI registration agency.

https://citation.crosscite.org/docs.html#sec-2

“Content negotiated requests to doi.org that ask for a content type which isn’t”text/html” will be redirected to a metadata service hosted by the DOI’s registration agency. Crossref, DataCite and mEDRA support content negotiated DOIs via their respective resolvers.”

However, it seems that the content is returned by doi.org.

for request_history in doi_content.history:
    print(request_history.status_code, request_history.url)
302 https://doi.org/10.7910/DVN/BUWAAF

A request to http://doi.org is redirected to https://doi.org, but there is no further redirect to a DOI registration agency.

doi_url = f"http://doi.org/{doi}"
headers = {"accept": "text/x-bibliography"}

r = requests.get(doi_url, headers=headers)

for request_history in r.history:
    print(request_history.status_code, request_history.url)
301 http://doi.org/10.1016/j.electstud.2016.07.002
302 https://doi.org/10.1016/j.electstud.2016.07.002