{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "k6HfuEZe48LV" }, "source": [ "### Query Crossref for works authored by a person\n", "This notebook queries the [Crossref API](http://api.crossref.org) via its `'/works'` endpoint for works authored by a person. It takes an ORCID URL or ORCID iD as input which is used to filter for all works where one of the authors' `orcid` field matches the given ORCID iD.\n", "From the resulting list of works we output all DOIs." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "id": "aV_HkXxJ4pVB", "scrolled": true }, "outputs": [], "source": [ "# Prerequisites:\n", "import requests # dependency to make HTTP calls\n", "from habanero import Crossref # lib for querying crossref api" ] }, { "cell_type": "markdown", "metadata": { "id": "4z7u62G76IBh" }, "source": [ "The input for this notebook is an ORCID URL or ORCID iD, e.g. '`https://orcid.org/0000-0003-2499-7741`' or '`0000-0003-2499-7741`'" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "executionInfo": { "elapsed": 14, "status": "ok", "timestamp": 1643057865676, "user": { "displayName": "Sandra M", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjjehryRcYlqHNFf_9Q6slGN_VZPE0y5QkvOxzG=s64", "userId": "04602594913862593282" }, "user_tz": -60 }, "id": "rbQX-rGA6M6B" }, "outputs": [], "source": [ "# input parameter\n", "example_orcid=\"https://orcid.org/0000-0003-2499-7741\"" ] }, { "cell_type": "markdown", "metadata": { "id": "uYK5apGy6i4f" }, "source": [ "We use it to query the Crossref API via its '`/works`' endpoint and set a filter for the `orcid` field to match the given ORCID iD." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "executionInfo": { "elapsed": 485, "status": "ok", "timestamp": 1643057866151, "user": { "displayName": "Sandra M", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjjehryRcYlqHNFf_9Q6slGN_VZPE0y5QkvOxzG=s64", "userId": "04602594913862593282" }, "user_tz": -60 }, "id": "AIuILzlS6zv9" }, "outputs": [], "source": [ "# we are using an existing library for querying the api crossref\n", "orcid_id= example_orcid.replace(\"https://orcid.org/\", \"\")\n", "list_of_pages=Crossref().works(filter = {'orcid': orcid_id}, cursor = \"*\", select = \"DOI,title\")" ] }, { "cell_type": "markdown", "metadata": { "id": "CpHKzkCu281O" }, "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." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "executionInfo": { "elapsed": 6, "status": "ok", "timestamp": 1643057866152, "user": { "displayName": "Sandra M", "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjjehryRcYlqHNFf_9Q6slGN_VZPE0y5QkvOxzG=s64", "userId": "04602594913862593282" }, "user_tz": -60 }, "id": "0bW0T-cv25wN", "outputId": "247e242b-c97a-47aa-dd5b-a80334ea1c42" }, "outputs": [ { "name": "stdout", "output_type": "stream", "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" ] } ], "source": [ "#-- example execution\n", "for page in list_of_pages:\n", " for item in page['message']['items']:\n", " print(f\"{item['DOI']}, {item['title'][0]}\")" ] } ], "metadata": { "colab": { "authorship_tag": "ABX9TyN8GdEZ2emA2pb1j6K+9PwP", "name": "crossref_get_works_by_person.ipynb", "provenance": [ { "file_id": "1RvDBYtHIK8LG_31cmfKW2PxQ3whxondX", "timestamp": 1643057922530 } ] }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.6" } }, "nbformat": 4, "nbformat_minor": 1 }