Skip to main content

API client for ORCID API

Project description

PyOrcid: An API client for ORCID API

Python3 dotenv urllib requests Tests

Overview

PyOrcid is a Python library and API client designed to simplify interactions with the ORCID API. ORCID (Open Researcher and Contributor ID) is a nonprofit organization that provides unique identifiers to researchers, ensuring their work is accurately attributed and discoverable. PyOrcid enables developers to seamlessly integrate ORCID functionality into their software, allowing users to collect, track, and sync their publication materials, research activities, and other related information.

Official ORCID documentation

Check out the methods, scopes, and examples mentioned in official documentation here.

QuickStart

pip install PyOrcid

Two ways to access public ORCID data

  1. Access through Orcid API

    You can get read/update access if you use Orcid API (note: update feature available only with member API). This is the official and most trusted way to get access. There are public and member APIs.

    You will need:

    • Developer's Application details (for authorization)
    • Orcid ID and corresponding access token of any researcher/user (for reading data)
    • Member API has extra authentication steps
  2. Access through OrcidScrapper feature of PyOrcid

    You will only get to read the public Orcid records. This is simplest way and an alternative to using API. Doesn't require any authorization.

    You will need:

    • Orcid ID of the reasearcher/user(for reading data)

Access through ORCID API

1. Developer : Registering your application

Skip this step if you already have details of client ID, client secret and a redirect uri of authorized application

To access the Public ORCID API, you need to register and authenticate yourself by registering an applications.

If you need access to other people's orcid profile, register your application and pass along your application details to them (they need to execute step 2 to give you access).

  1. Create an ORCID Account: If you don't already have an ORCID account, you'll need to create one. Visit the ORCID website and sign up for an account.

  2. Access Developer Tools: Once you've logged into your ORCID account, navigate to "Your Profile." From there, select "Developer Tools."

  3. Obtain Client Credentials: In the Developer Tools section, you'll be able to generate your developer credentials:

    • Client ID: You will receive a client_id that uniquely identifies your application.
    • Client Secret: You'll also be provided with a client_secret for secure communication.
  4. Register Redirect URI: Register a redirect_uri for your application. This URI is where users will be redirected after authorizing your application's access to their ORCID data. Make sure to specify these URIs in advance to prevent errors during integration. You can use your GitHub repository URL or any other URL under your control as the redirect_uri.

More detailed steps mentioned here to access public API.

To access the Member API, follow these instructions.

2. After registering your application

You need to get an access token. Getting an access-token depends on whether a method/scope require user authorization.

Get the client_id, client_secret and redirect_uri details from your registered application.

a) For reading public-access data of a public profile

By executing following code, you will get an access-token to read (publid-access) data of a public profile. This doesn't require user authorization. Don't need to provide any value for redirect_uri.

You can use this token to access any number of public profiles.

from pyorcid import OrcidAuthentication

# redirect_uri  is not required
orcid_auth = OrcidAuthentication(client_id="APP-xxxxxxxx", client_secret="xx-xx-xxxx-xxx")

access_token = orcid_auth.get_public_access_token()

b) For Member API or reading limited-access data of public profile

By executing following code, the user will be redirected to orcid authorization page. Once the user authorizes your application, they will be redirected to "redirected_uri" you registered. Copy and paste the full URL of redirected page (contains special code) in terminal. Please save it for future use or else the application has to be authorized everytime.

This token is exclusively for the user who granted access.

from pyorcid import OrcidAuthentication

# Authenticate your application 
# Any valid user can authorize your application by running the following command 
orcid_auth = OrcidAuthentication(client_id="APP-xxxxxxxx", client_secret="xx-xx-xxxx-xxx",      
                                 redirect_uri="https://github.com/user")

access_token = orcid_auth.get_private_access_token()

Executing this line of code:

  • Click the URL as mentioned in output, which will redirect the user to orcid website.
  • It will ask the user whether to authorize your application.
  • After your application is authorized, user will be redirected to application's redirect_uri with a code. Copy and paste the full URL in the terminal input prompt. Then, you will obtain an access_token. Most probably, this token will not expire for around 20 years. So, make sure to save it, otherwise user have to re-authorize your application.

3.After Authentication

To utilize the functionalities offered by this package, you have access to a variety of methods. To get started, you'll require the ORCID IDs of the researchers or users whose data you intend to access, as well as the access token that is received after the user authorized your application to interact with their ORCID profiles. For instance

from pyorcid import Orcid

#Orcid ID of the user
orcid_id = 'xxxx-xxxx-xxxx-xxxx'

#this is the access token obtained either of above auth methods
access_token = "xxxx-xxxxxxxxxxx-xxxxxxx-xxx" 
#create an instance of the Orcid class
# state defines which ORCID API you want to use: public or member
orcid = Orcid(orcid_id=orcid_id, orcid_access_token=access_token, state = "public")
orcid.__dir__()
# Get the information of user's works from their ORCID profile
works_data = orcid.works()[0]
for work in works_data:
   for key, value in work.items():
       print(key, value)
# Generate a markdown file with the summary of various section's data
orcid.generate_markdown_file(output_file = "md_generator_example.md")

Searching ORCID records

from pyorcid import OrcidSearch
#search through ORCID records, for details on the query format see https://info.orcid.org/documentation/api-tutorials/api-tutorial-searching-the-orcid-registry/  
orcidSearch = OrcidSearch(orcid_access_token=access_token)
orcidSearch.search("John Smith")

Access through OrcidScrapper feature of PyOrcid

This is an alternative to Orcid API. You can only read the orcid profiles on public database. All you need is the Orcid ID of the researchers you wish to retrieve. OrcidScrapper can access all methods of Orcid class as it is inherited from it.

from src import pyorcid
orcid_id = 'xxxx-xxxx-xxxx-xxxx'
orcid = pyorcid.OrcidScrapper(orcid_id=orcid_id)
orcid.__dir__()
works_data = orcid.works()[0]
for work_obj in works_data:
    print(work_obj)

orcid.record_summary()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyorcid-1.2.2.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyorcid-1.2.2-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file pyorcid-1.2.2.tar.gz.

File metadata

  • Download URL: pyorcid-1.2.2.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.0 Windows/11

File hashes

Hashes for pyorcid-1.2.2.tar.gz
Algorithm Hash digest
SHA256 ed318a2984fb96e0a5ad9902e3f0aa7fed13d668785ee224f58287da589fd8a4
MD5 81da21c5fb16814bc7f18b7eb13b3d98
BLAKE2b-256 63765057a000367efa0af53db55484d2c776f1d186cec284542b704fcfa4e24e

See more details on using hashes here.

File details

Details for the file pyorcid-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: pyorcid-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.0 Windows/11

File hashes

Hashes for pyorcid-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 43acc41d69dc2b0794e67fc1af61ffd06743aaf42234fbc499bce153496bd8c8
MD5 0c511b92846fc6108d1f6ee2999bab2f
BLAKE2b-256 7506e9aaf1468318afd5e5098997196cb070ec1e80e3d424963c0ea88f8a0742

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page