Crossref Commons
High-level library for getting data from Crossref APIs (REST, XML, ...). Work in progress.
Installation
pip3 install crossref-commons
Usage
Retrieving entities
Entities of various types can be retrieved by giving their respective IDs:
import crossref_commons.retrieval
crossref_commons.retrieval.get_publication_as_json('10.5621/sciefictstud.40.2.0382')
crossref_commons.retrieval.get_publication_as_xml('10.5621/sciefictstud.40.2.0382')
crossref_commons.retrieval.get_publication_as_refstring('10.5621/sciefictstud.40.2.0382', 'ieee')
crossref_commons.retrieval.get_member_as_json('15')
Equivalently, you can use get_entity function to retrieve any type of entity:
from crossref_commons.retrieval import get_entity
from crossref_commons.types import EntityType, OutputType
get_entity('10.5621/sciefictstud.40.2.0382', EntityType.PUBLICATION, OutputType.JSON)
get_entity('10.5621/sciefictstud.40.2.0382', EntityType.PUBLICATION, OutputType.XML)
get_entity('10.5621/sciefictstud.40.2.0382', EntityType.PUBLICATION, OutputType.REFSTRING, 'ieee')
get_entity('15', EntityType.MEMBER, OutputType.JSON)
Retrieving relations
Currently, aliases and general relations are supported:
from crossref_commons.relations import get_related
get_related('10.1167/18.8.6')
Iterating
It is possible to iterate over publications meeting specific criteria (JSON only):
from crossref_commons.iteration import iterate_publications_as_json
filter = {'funder': '10.13039/501100000038', 'type': 'journal-article'}
queries = {'query.author': 'li', 'query.affiliation': 'university'}
for p in iterate_publications_as_json(max_results=189, filter=filter, queries=queries):
print(p['DOI'])
Sampling
Instead of iterating over the items meeting the criteria, in some cases it is better to use a random sample. get_sample will automatically handle sizes larger than Crossref REST API's limit of 100:
from crossref_commons.sampling import get_sample
filter = {'funder': '10.13039/501100000038', 'type': 'journal-article'}
queries = {'query.author': 'li', 'query.affiliation': 'university'}
sample = get_sample(size=121, filter=filter, queries=queries)
Authorization
You can set the Polite information and/or Plus token by creating a file ~/.crapi_key with the following content:
{
"Crossref-Plus-API-Token": "<<Plus API token, for Plus users only>>",
"User-Agent": "<<polite user agent; including mailto:email address>>",
"Mailto": "<<email address>>"
}
Alternatively, the same information can be provided through environment variables CR_API_PLUS, CR_API_AGENT and CR_API_MAILTO.
Metadata
Release files for crossref-commons 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| crossref_commons-0.0.7.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| crossref_commons-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.9 kB
Release files / crossref_commons-0.0.7.tar.gz
| Download URL | crossref_commons-0.0.7.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b8ae35d48acc4fe62da1662525396477e4f8c76fdb00cd42d5334c68713c4b6
|
|
BLAKE2b-256 checksum How to use checksums |
8a9da69673e371afa0d77edcb0cc8dfb6b05ccd9e1ffe879ca7804cf32e7851c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.10
|
Release files / crossref_commons-0.0.7-py3-none-any.whl
| Download URL | crossref_commons-0.0.7-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab4f7a62a7745cf70ef68ffdebbb58091493db324a269f29df915f6f43bdf130
|
|
BLAKE2b-256 checksum How to use checksums |
aa83c4d638f2f34ef722f8e655fa86d39215f36b8607a7927af2f2ebe5434431
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.10
|