The ORCID API documentation is here.
import requests
requests.__version__
'2.22.0'
ORCID = '0000-0002-9653-4458'
ORCID_URL = "http://pub.orcid.org/%s/orcid-works"
DOI_BASE_URL = 'http://dx.doi.org/'
headers = {'accept': 'application/orcid+json'}
r = requests.get(ORCID_URL % ORCID, headers=headers)
print (r.ok)
False
printr.headers
{'Server': 'nginx/1.10.0', 'Date': 'Sun, 24 Nov 2019 13:50:14 GMT', 'Content-Type': 'application/orcid+json; qs=2;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-XSS-Protection': '1; mode=block', 'X-Frame-Options': 'DENY', 'X-Content-Type-Options': 'nosniff', 'Content-Encoding': 'gzip'}
print r.content
{"message-version":"1.0.15","orcid-profile":{"orcid":{"value":"0000-0002-9653-4458"},"orcid-id":"http://orcid.org/0000-0002-9653-4458","orcid-history":{"creation-method":"WEBSITE","completion-date":{"value":1350396328015},"submission-date":{"value":1350392628869},"last-modified-date":{"value":1373804852054},"claimed":{"value":true},"source":null,"visibility":null},"orcid-activities":{"orcid-works":{"orcid-work":[{"put-code":"9381344","work-title":{"title":{"value":"Dispersing away from bad genotypes: the evolution of Fitness-Associated Dispersal (FAD) in homogeneous environments"},"subtitle":{"value":"BMC Evolutionary Biology"}},"work-citation":{"work-citation-type":"BIBTEX","citation":"@article{Gueijman_Ayali_Ram_Hadany_2013, title={Dispersing away from bad genotypes: the evolution of Fitness-Associated Dispersal (FAD) in homogeneous environments}, volume={13}, url={http://dx.doi.org/10.1186/1471-2148-13-125}, DOI={10.1186/1471-2148-13-125}, number={1}, journal={BMC Evolutionary Biology}, publisher={Springer (Biomed Central Ltd.)}, author={Gueijman, Ariel and Ayali, Amir and Ram, Yoav and Hadany, Lilach}, year={2013}, pages={125}}"},"work-type":"JOURNAL_ARTICLE","publication-date":{"year":{"value":"2013"},"month":null,"day":null,"media-type":null},"work-external-identifiers":{"work-external-identifier":[{"work-external-identifier-type":"DOI","work-external-identifier-id":{"value":"10.1186/1471-2148-13-125"}},{"work-external-identifier-type":"ISSN","work-external-identifier-id":{"value":"1471-2148"}}],"scope":null},"url":null,"work-source":{"value":"0000-0002-3054-1567"},"visibility":null},{"put-code":"9381343","work-title":{"title":{"value":"EVOLUTION OF STRESS-INDUCED HYPERMUTATION"},"subtitle":{"value":"Evolution"}},"work-citation":{"work-citation-type":"BIBTEX","citation":"@article{Ram_Hadany_2012, title={THE EVOLUTION OF STRESS-INDUCED HYPERMUTATION IN ASEXUAL POPULATIONS}, volume={66}, url={http://dx.doi.org/10.1111/j.1558-5646.2012.01576.x}, DOI={10.1111/j.1558-5646.2012.01576.x}, number={7}, journal={Evolution}, publisher={Wiley Blackwell (Blackwell Publishing)}, author={Ram, Yoav and Hadany, Lilach}, year={2012}, month={Jul}, pages={2315-2328}}"},"work-type":"JOURNAL_ARTICLE","publication-date":{"year":{"value":"2012"},"month":null,"day":null,"media-type":null},"work-external-identifiers":{"work-external-identifier":[{"work-external-identifier-type":"DOI","work-external-identifier-id":{"value":"10.1111/j.1558-5646.2012.01576.x"}},{"work-external-identifier-type":"ISSN","work-external-identifier-id":{"value":"0014-3820"}}],"scope":null},"url":null,"work-source":{"value":"0000-0002-3054-1567"},"visibility":null}],"scope":null}},"type":"USER"}}
data = r.json()
print data
{u'message-version': u'1.0.15', u'orcid-profile': {u'orcid': {u'value': u'0000-0002-9653-4458'}, u'orcid-id': u'http://orcid.org/0000-0002-9653-4458', u'type': u'USER', u'orcid-activities': {u'orcid-works': {u'scope': None, u'orcid-work': [{u'put-code': u'9381344', u'work-title': {u'subtitle': {u'value': u'BMC Evolutionary Biology'}, u'title': {u'value': u'Dispersing away from bad genotypes: the evolution of Fitness-Associated Dispersal (FAD) in homogeneous environments'}}, u'work-citation': {u'citation': u'@article{Gueijman_Ayali_Ram_Hadany_2013, title={Dispersing away from bad genotypes: the evolution of Fitness-Associated Dispersal (FAD) in homogeneous environments}, volume={13}, url={http://dx.doi.org/10.1186/1471-2148-13-125}, DOI={10.1186/1471-2148-13-125}, number={1}, journal={BMC Evolutionary Biology}, publisher={Springer (Biomed Central Ltd.)}, author={Gueijman, Ariel and Ayali, Amir and Ram, Yoav and Hadany, Lilach}, year={2013}, pages={125}}', u'work-citation-type': u'BIBTEX'}, u'work-type': u'JOURNAL_ARTICLE', u'publication-date': {u'month': None, u'day': None, u'media-type': None, u'year': {u'value': u'2013'}}, u'visibility': None, u'url': None, u'work-external-identifiers': {u'scope': None, u'work-external-identifier': [{u'work-external-identifier-id': {u'value': u'10.1186/1471-2148-13-125'}, u'work-external-identifier-type': u'DOI'}, {u'work-external-identifier-id': {u'value': u'1471-2148'}, u'work-external-identifier-type': u'ISSN'}]}, u'work-source': {u'value': u'0000-0002-3054-1567'}}, {u'put-code': u'9381343', u'work-title': {u'subtitle': {u'value': u'Evolution'}, u'title': {u'value': u'EVOLUTION OF STRESS-INDUCED HYPERMUTATION'}}, u'work-citation': {u'citation': u'@article{Ram_Hadany_2012, title={THE EVOLUTION OF STRESS-INDUCED HYPERMUTATION IN ASEXUAL POPULATIONS}, volume={66}, url={http://dx.doi.org/10.1111/j.1558-5646.2012.01576.x}, DOI={10.1111/j.1558-5646.2012.01576.x}, number={7}, journal={Evolution}, publisher={Wiley Blackwell (Blackwell Publishing)}, author={Ram, Yoav and Hadany, Lilach}, year={2012}, month={Jul}, pages={2315-2328}}', u'work-citation-type': u'BIBTEX'}, u'work-type': u'JOURNAL_ARTICLE', u'publication-date': {u'month': None, u'day': None, u'media-type': None, u'year': {u'value': u'2012'}}, u'visibility': None, u'url': None, u'work-external-identifiers': {u'scope': None, u'work-external-identifier': [{u'work-external-identifier-id': {u'value': u'10.1111/j.1558-5646.2012.01576.x'}, u'work-external-identifier-type': u'DOI'}, {u'work-external-identifier-id': {u'value': u'0014-3820'}, u'work-external-identifier-type': u'ISSN'}]}, u'work-source': {u'value': u'0000-0002-3054-1567'}}]}}, u'orcid-history': {u'source': None, u'creation-method': u'WEBSITE', u'submission-date': {u'value': 1350392628869L}, u'last-modified-date': {u'value': 1373804852054L}, u'visibility': None, u'completion-date': {u'value': 1350396328015L}, u'claimed': {u'value': True}}}}
type(data),len(data)
(dict, 2)
data.keys()
[u'message-version', u'orcid-profile']
data['message-version']
u'1.0.15'
data = data['orcid-profile']
data.keys()
[u'orcid', u'orcid-id', u'type', u'orcid-activities', u'orcid-history']
data = data['orcid-activities']
data.keys()
[u'orcid-works']
data['orcid-works'].keys()
[u'scope', u'orcid-work']
data = data['orcid-works']['orcid-work']
type(data),len(data)
(list, 2)
data[0].keys()
[u'put-code', u'work-title', u'work-citation', u'work-type', u'publication-date', u'visibility', u'url', u'work-external-identifiers', u'work-source']
title = data[0]['work-title']['title']['value']
print title
Dispersing away from bad genotypes: the evolution of Fitness-Associated Dispersal (FAD) in homogeneous environments
bibtex = data[0]['work-citation']['citation']
print bibtex
@article{Gueijman_Ayali_Ram_Hadany_2013, title={Dispersing away from bad genotypes: the evolution of Fitness-Associated Dispersal (FAD) in homogeneous environments}, volume={13}, url={http://dx.doi.org/10.1186/1471-2148-13-125}, DOI={10.1186/1471-2148-13-125}, number={1}, journal={BMC Evolutionary Biology}, publisher={Springer (Biomed Central Ltd.)}, author={Gueijman, Ariel and Ayali, Amir and Ram, Yoav and Hadany, Lilach}, year={2013}, pages={125}}
data[0]['publication-date']['year']['value']
u'2013'
journal = data[0]['work-title']['subtitle']['value']
print journal
u'BMC Evolutionary Biology'
url = ''
if data[0]['url']:
url = data[0]['url']['value']
print url
doi = ''
for v in data[0]['work-external-identifiers']['work-external-identifier']:
if v['work-external-identifier-type'] == 'DOI':
doi = v['work-external-identifier-id']['value']
url = DOI_BASE_URL + doi
print doi
print url
10.1186/1471-2148-13-125 http://dx.doi.org/10.1186/1471-2148-13-125
def parse_item(data):
title = data['work-title']['title']['value']
citation = data['work-citation']['citation']
journal = data['work-title']['subtitle']['value']
url = ''
if data['url']:
url = data[0]['url']['value']
doi = ''
for v in data['work-external-identifiers']['work-external-identifier']:
if v['work-external-identifier-type'] == 'DOI':
doi = v['work-external-identifier-id']['value']
url = DOI_BASE_URL + doi
return {'title':title, 'journal':journal, 'url':url, 'doi':doi, 'citation':citation}
parse_item(data[1])
{'citation': u'@article{Ram_Hadany_2012, title={THE EVOLUTION OF STRESS-INDUCED HYPERMUTATION IN ASEXUAL POPULATIONS}, volume={66}, url={http://dx.doi.org/10.1111/j.1558-5646.2012.01576.x}, DOI={10.1111/j.1558-5646.2012.01576.x}, number={7}, journal={Evolution}, publisher={Wiley Blackwell (Blackwell Publishing)}, author={Ram, Yoav and Hadany, Lilach}, year={2012}, month={Jul}, pages={2315-2328}}', 'doi': u'10.1111/j.1558-5646.2012.01576.x', 'journal': u'Evolution', 'title': u'EVOLUTION OF STRESS-INDUCED HYPERMUTATION', 'url': u'http://dx.doi.org/10.1111/j.1558-5646.2012.01576.x'}
def extract_items(request):
data = request.json()
data = data['orcid-profile']
data = data['orcid-activities']
data = data['orcid-works']['orcid-work']
return [parse_item(item) for item in data]
extract_items(r)
[{'citation': u'@article{Gueijman_Ayali_Ram_Hadany_2013, title={Dispersing away from bad genotypes: the evolution of Fitness-Associated Dispersal (FAD) in homogeneous environments}, volume={13}, url={http://dx.doi.org/10.1186/1471-2148-13-125}, DOI={10.1186/1471-2148-13-125}, number={1}, journal={BMC Evolutionary Biology}, publisher={Springer (Biomed Central Ltd.)}, author={Gueijman, Ariel and Ayali, Amir and Ram, Yoav and Hadany, Lilach}, year={2013}, pages={125}}', 'doi': u'10.1186/1471-2148-13-125', 'journal': u'BMC Evolutionary Biology', 'title': u'Dispersing away from bad genotypes: the evolution of Fitness-Associated Dispersal (FAD) in homogeneous environments', 'url': u'http://dx.doi.org/10.1186/1471-2148-13-125'}, {'citation': u'@article{Ram_Hadany_2012, title={THE EVOLUTION OF STRESS-INDUCED HYPERMUTATION IN ASEXUAL POPULATIONS}, volume={66}, url={http://dx.doi.org/10.1111/j.1558-5646.2012.01576.x}, DOI={10.1111/j.1558-5646.2012.01576.x}, number={7}, journal={Evolution}, publisher={Wiley Blackwell (Blackwell Publishing)}, author={Ram, Yoav and Hadany, Lilach}, year={2012}, month={Jul}, pages={2315-2328}}', 'doi': u'10.1111/j.1558-5646.2012.01576.x', 'journal': u'Evolution', 'title': u'EVOLUTION OF STRESS-INDUCED HYPERMUTATION', 'url': u'http://dx.doi.org/10.1111/j.1558-5646.2012.01576.x'}]
def orcid_items(orcid):
headers = {'accept': 'application/orcid+json'}
r = requests.get(ORCID_URL % orcid, headers=headers)
if r.ok:
return extract_items(r)
else:
return []
orcid_items(ORCID)
[{'citation': u'@article{Gueijman_Ayali_Ram_Hadany_2013, title={Dispersing away from bad genotypes: the evolution of Fitness-Associated Dispersal (FAD) in homogeneous environments}, volume={13}, url={http://dx.doi.org/10.1186/1471-2148-13-125}, DOI={10.1186/1471-2148-13-125}, number={1}, journal={BMC Evolutionary Biology}, publisher={Springer (Biomed Central Ltd.)}, author={Gueijman, Ariel and Ayali, Amir and Ram, Yoav and Hadany, Lilach}, year={2013}, pages={125}}', 'doi': u'10.1186/1471-2148-13-125', 'journal': u'BMC Evolutionary Biology', 'title': u'Dispersing away from bad genotypes: the evolution of Fitness-Associated Dispersal (FAD) in homogeneous environments', 'url': u'http://dx.doi.org/10.1186/1471-2148-13-125'}, {'citation': u'@article{Ram_Hadany_2012, title={THE EVOLUTION OF STRESS-INDUCED HYPERMUTATION IN ASEXUAL POPULATIONS}, volume={66}, url={http://dx.doi.org/10.1111/j.1558-5646.2012.01576.x}, DOI={10.1111/j.1558-5646.2012.01576.x}, number={7}, journal={Evolution}, publisher={Wiley Blackwell (Blackwell Publishing)}, author={Ram, Yoav and Hadany, Lilach}, year={2012}, month={Jul}, pages={2315-2328}}', 'doi': u'10.1111/j.1558-5646.2012.01576.x', 'journal': u'Evolution', 'title': u'EVOLUTION OF STRESS-INDUCED HYPERMUTATION', 'url': u'http://dx.doi.org/10.1111/j.1558-5646.2012.01576.x'}]