API client for ORCID API
Project description
PyOrcid: An API client for ORCID API
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
-
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
-
Access through OrcidScrapper feature of PyOrcid
You will only get to read the public Orcid records. This is the simplest and quickest way and 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).
-
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.
-
Access Developer Tools: Once you've logged into your ORCID account, navigate to "Your Profile." From there, select "Developer Tools."
-
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.
- Client ID: You will receive a
-
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 theredirect_uri
.
More detailed steps mentioned here to access public API.
To access the Member API, follow these instructions.
2. After registering your application
Users can now authorize your application. Pass the necessary details to them and let them execute follow command.
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. After copy/pasting full URL of redirected page (contains special code), access token will be shown in output. Please save it for future use or else the application has to be authorized everytime.
Get the client_id
, client_secret
and redirect_uri
details from your registered application.
from pyorcid import OrcidAuthentication
# Authenticate your application
# Any valid user can authorize your application by running the following command
OrcidAuthentication(client_id="APP-xxxxxxxx", client_secret="xx-xx-xxxx-xxx", redirect_uri="https://github.com/user")
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'
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 key, value in works_data.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")
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 = '0000-0003-0666-9883'
orcid = pyorcid.OrcidScrapper(orcid_id=orcid_id)
orcid.__dir__()
works_data = orcid.works()[0]
for key, value in works_data.items():
print(key, value)
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
Built Distribution
File details
Details for the file pyorcid-1.1.1.tar.gz
.
File metadata
- Download URL: pyorcid-1.1.1.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38a48108fde70b8371bb09e1f6b0df01b153ecc517d6e142b576eb9921bc80a2 |
|
MD5 | 44d6beb3fd760ba472758040e9a72a20 |
|
BLAKE2b-256 | 47d964e63a2568f0f7d1e9c85d686f2794ea05d84f177e5fe6ec3878b67d089e |
Provenance
File details
Details for the file pyorcid-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: pyorcid-1.1.1-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 150e2113915577f6f1987c0376f3aebab418c096e46b99e83f5eacb2d91f0e47 |
|
MD5 | 5379dee6fb7074f3e15cb07d9273cae0 |
|
BLAKE2b-256 | e990454008e3aa5e7a1b31a9f23ff05719c2de4863c284fa417193c2ea319a8c |