+{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"Kopie von crossref_get_works_by_person.ipynb","provenance":[{"file_id":"1RvDBYtHIK8LG_31cmfKW2PxQ3whxondX","timestamp":1643057922530}],"authorship_tag":"ABX9TyN8GdEZ2emA2pb1j6K+9PwP"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","source":["### Query Crossref for all works authored by a person\n","This notebook queries the [Crossref API](http://api.crossref.org) via its `/works` endpoint for all works authored by a person. It takes an ORCID URL as input which is used to filter for all works where one of the authors' ORCID field matches the given ORCID URL.\n","From the resulting list of works we output their respective DOIs."],"metadata":{"id":"k6HfuEZe48LV"}},{"cell_type":"code","execution_count":null,"metadata":{"id":"aV_HkXxJ4pVB"},"outputs":[],"source":["# Prerequisite: needed dependency to make HTTP calls\n","import requests\n","# lib for querying crossref api\n","!pip install habanero"]},{"cell_type":"markdown","source":["The input for the query is an ORCID URL or an ORCID iD."],"metadata":{"id":"4z7u62G76IBh"}},{"cell_type":"code","source":["# input parameter\n","example_orcid=\"https://orcid.org/0000-0003-2499-7741\""],"metadata":{"id":"rbQX-rGA6M6B","executionInfo":{"status":"ok","timestamp":1643057865676,"user_tz":-60,"elapsed":14,"user":{"displayName":"Sandra M","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjjehryRcYlqHNFf_9Q6slGN_VZPE0y5QkvOxzG=s64","userId":"04602594913862593282"}}},"execution_count":2,"outputs":[]},{"cell_type":"markdown","source":["We use it to query the Crossref API via its '`/works`' endpoint and set a filter for the given ORCID iD."],"metadata":{"id":"uYK5apGy6i4f"}},{"cell_type":"code","source":["# fortunately there are existing libraries for querying Crossref \n","from habanero import Crossref\n","cr = Crossref()\n","\n","orcid_id= example_orcid.replace(\"https://orcid.org/\", \"\")\n","list_of_pages=cr.works(filter = {'orcid': orcid_id}, cursor = \"*\", select = \"DOI,title\")"],"metadata":{"id":"AIuILzlS6zv9","executionInfo":{"status":"ok","timestamp":1643057866151,"user_tz":-60,"elapsed":485,"user":{"displayName":"Sandra M","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjjehryRcYlqHNFf_9Q6slGN_VZPE0y5QkvOxzG=s64","userId":"04602594913862593282"}}},"execution_count":3,"outputs":[]},{"cell_type":"markdown","source":["Since the Crossref API uses pagination, we need to loop through all pages to get the complete result set. We print out title and DOI of each work in the result set."],"metadata":{"id":"CpHKzkCu281O"}},{"cell_type":"code","source":["#-- example execution\n","for page in list_of_pages:\n"," for item in page['message']['items']:\n"," doi=item['DOI']\n"," print(f\"{item['DOI']}, {item['title'][0]}\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"0bW0T-cv25wN","executionInfo":{"status":"ok","timestamp":1643057866152,"user_tz":-60,"elapsed":6,"user":{"displayName":"Sandra M","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjjehryRcYlqHNFf_9Q6slGN_VZPE0y5QkvOxzG=s64","userId":"04602594913862593282"}},"outputId":"247e242b-c97a-47aa-dd5b-a80334ea1c42"},"execution_count":4,"outputs":[{"output_type":"stream","name":"stdout","text":["10.3897/rio.7.e66264, OPTIMETA – Strengthening the Open Access publishing system through open citations and spatiotemporal metadata \n","10.31263/voebm.v72i2.2808, Open Science und die Bibliothek – Aktionsfelder und Berufsbild\n","10.1080/19386389.2021.1999156, Roadmap to FAIR Research Information in Open Infrastructures\n","10.21105/joss.01182, VIVO: a system for research discovery\n","10.3897/rio.4.e31656, Reference implementation for open scientometric indicators (ROSI)\n"]}]}]}
0 commit comments