Package: unpywall
unpywall - Interfacing the Unpaywall API with PythonIntroductionunpywall is a Python client that utilizes theUnpaywall REST APIfor scholarly analysis withpandas. This package is influenced byroadoi, a R client that interacts with the Unpaywall API.You can find more about the Unpaywall service here:https://unpaywall.org/.The documentation about the Unpaywall REST API is located here:https://unpaywall.org/products/api.InstallInstall frompypiusing pip:pipinstallunpywallUseAuthenticationAn authentification is required to use the Unpaywall Service. For that, unpywall offers two options for authorizing the client. You can either importUnpywallCredentialswhich generates an environment variable or you can set the environment variable by yourself. Both methods require an email.fromunpywall.utilsimportUnpywallCredentialsUnpywallCredentials('nick.haupka@gmail.com')Notice that the environment variable for authentication needs to be calledUNPAYWALL_EMAIL.exportUNPAYWALL_EMAIL=nick.haupka@gmail.comQuery Unpaywall by DOIIf you want to search articles by a given DOI use the methoddoi. The result is apandas DataFrame.fromunpywallimportUnpywallUnpywall.doi(dois=['10.1038/nature12373','10.1093/nar/gkr1047'])#   data_standard  ... best_oa_location.version#0              2  ...         publishedVersion#1              2  ...         publishedVersion#[2 rows x 32 columns]You can track the progress of your API call by setting the parameterprogressto True. This is especially useful for estimating the time required.Unpywall.doi(dois=['10.1038/nature12373','10.1093/nar/gkr1047'],progress=True)#|=========================                        | 50%This method also allows two options for catching errors (raiseandignore)Unpywall.doi(dois=['10.1038/nature12373','10.1093/nar/gkr1047'],errors='ignore')Query Unpaywall by text searchIf you want to search articles by a given term use the methodquery. The result is apandas DataFrameUnpywall.query(query='sea lion',is_oa=True)#   data_standard  ... first_oa_location.version#0              2  ...          publishedVersion#1              2  ...          publishedVersion#2              2  ...          publishedVersionConveniently obtain full textIf you are using Unpaywall to obtain full-text copies of papers for literature mining, you may benefit from the following functions:You can use thedownload_pdf_handlemethod to return a PDF handle for the given DOI.Unpywall.download_pdf_handle(doi='10.1038/nature12373')#<http.client.HTTPResponse object at 0x7fd08ef677c0>To return an URL to a PDF for the given DOI, useget_pdf_link.Unpywall.get_pdf_link(doi='10.1038/nature12373')#'https://dash.harvard.edu/bitstream/1/12285462/1/Nanometer-Scale%20Thermometry.pdf'To return an URL to the best available OA copy, regardless of the format, useget_doc_link.Unpywall.get_doc_link(doi='10.1016/j.envint.2020.105730')#'https://doi.org/10.1016/j.envint.2020.105730'To return a list of all URLS to OA copies, useget_all_links.Unpywall.get_all_links(doi='10.1038/nature12373')#['https://dash.harvard.edu/bitstream/1/12285462/1/Nanometer-Scale%20Thermometry.pdf']You can also directly access all data provided by unpaywall in json format usingget_json.Unpywall.get_json(doi='10.1038/nature12373')#{'best_oa_location': {'endpoint_id': '8c9d8ba370a84253deb', 'evidence': 'oa repository (via OAI-PMH doi match)', 'host_type': ...Command-Line-Interfaceunpywall comes with a command-line-interface that can be used to quickly look up a PDF or to download free full-text articles to your device.Obtain a PDF URLRetrieve the URL of a PDF for a given DOI with the following command.unpywalllink10.1038/nature12373View a PDFIf you want to view a PDF in your Browser or on your system useview.unpywallview10.1038/nature12373-mbrowserPDF DownloadUsedownloadif you want to store a PDF on your machine.unpywalldownload10.1038/nature12373-farticle.pdf-p./documentsHelpYou can always usehelpto open a description for the provided functions.unpywall-hDocumentationFull documentation is available athttps://unpywall.readthedocs.io/.DevelopTo install unpywall, along with dev tools, run:pipinstall-e'.[dev]'