Skip to main content

Crossref Commons

Project description

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, only retrieving aliases is supported:

from crossref_commons.relations import get_alias

get_alias('10.1037//0022-3514.62.3.434')

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.

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

crossref_commons-0.0.6.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

crossref_commons-0.0.6-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file crossref_commons-0.0.6.tar.gz.

File metadata

  • Download URL: crossref_commons-0.0.6.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

File hashes

Hashes for crossref_commons-0.0.6.tar.gz
Algorithm Hash digest
SHA256 dc06f6153558e97783e06794e19ae2eca590a306a8b05689fd9104c7d8e4a411
MD5 ec2714c50d20348c9fdff9b5c378d684
BLAKE2b-256 c3a7d728ebcc0cac2514cc92e5c64ba017bf14e779b016c35457a74d11e01be2

See more details on using hashes here.

File details

Details for the file crossref_commons-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: crossref_commons-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

File hashes

Hashes for crossref_commons-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 83864db7422c0038629e085cd4274db55015ffa0b383a36456f35e7dbf4a4c94
MD5 2f5f6884e0cc71d5c9604ba8d383c931
BLAKE2b-256 263676651ca1ccd2df5efe56ab516931547dd443733dfaa35c884d4a0752a1c4

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