Reading meta data from DOI.org#
In this notebook we will access meta data of records on https://doi.org .
import requests
import json
For this, we write a little helper function.
def read_doi(doi):
"""
Reads meta data of records in doi.org.
"""
doi = doi.replace("https://doi.org/", "")
url = "https://doi.org/api/handles/" + doi
# Download the file
response = requests.get(url)
data = response.json()
return data
We can then call the function and store the results in a data
object.
data = read_doi("https://doi.org/10.5281/zenodo.3833824")
data
{'responseCode': 1,
'handle': '10.5281/zenodo.3833824',
'values': [{'index': 100,
'type': 'HS_ADMIN',
'data': {'format': 'admin',
'value': {'handle': '10.admin/codata',
'index': 300,
'permissions': '111111111111'}},
'ttl': 86400,
'timestamp': '2020-05-19T10:28:11Z'},
{'index': 1,
'type': 'URL',
'data': {'format': 'string', 'value': 'https://zenodo.org/record/3833824'},
'ttl': 86400,
'timestamp': '2020-05-19T10:28:11Z'}]}
This json object consists of Python dictionaries and lists. We can navigate through those and extract information.
data['values'][0]
{'index': 100,
'type': 'HS_ADMIN',
'data': {'format': 'admin',
'value': {'handle': '10.admin/codata',
'index': 300,
'permissions': '111111111111'}},
'ttl': 86400,
'timestamp': '2020-05-19T10:28:11Z'}
Exercise#
Find out the author(s) of the DOI above.