crossref-commons


Namecrossref-commons JSON
Version 0.0.7 PyPI version JSON
download
home_pagehttps://gitlab.com/crossref/crossref_commons_py
SummaryCrossref Commons
upload_time2020-01-13 19:37:29
maintainer
docs_urlNone
authorCrossref
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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`.



            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/crossref/crossref_commons_py",
    "name": "crossref-commons",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Crossref",
    "author_email": "labs@crossref.org",
    "download_url": "https://files.pythonhosted.org/packages/8a/9d/a69673e371afa0d77edcb0cc8dfb6b05ccd9e1ffe879ca7804cf32e7851c/crossref_commons-0.0.7.tar.gz",
    "platform": "",
    "description": "# Crossref Commons\n\nHigh-level library for getting data from Crossref APIs (REST, XML, ...). Work in progress.\n\n## Installation\n\n    pip3 install crossref-commons\n\n## Usage\n\n### Retrieving entities\n\nEntities of various types can be retrieved by giving their respective IDs:\n\n    import crossref_commons.retrieval\n\n    crossref_commons.retrieval.get_publication_as_json('10.5621/sciefictstud.40.2.0382')\n    crossref_commons.retrieval.get_publication_as_xml('10.5621/sciefictstud.40.2.0382')\n    crossref_commons.retrieval.get_publication_as_refstring('10.5621/sciefictstud.40.2.0382', 'ieee')\n\n    crossref_commons.retrieval.get_member_as_json('15')\n\nEquivalently, you can use `get_entity` function to retrieve any type of entity:\n\n    from crossref_commons.retrieval import get_entity\n    from crossref_commons.types import EntityType, OutputType\n\n    get_entity('10.5621/sciefictstud.40.2.0382', EntityType.PUBLICATION, OutputType.JSON)\n    get_entity('10.5621/sciefictstud.40.2.0382', EntityType.PUBLICATION, OutputType.XML)\n    get_entity('10.5621/sciefictstud.40.2.0382', EntityType.PUBLICATION, OutputType.REFSTRING, 'ieee')\n\n    get_entity('15', EntityType.MEMBER, OutputType.JSON)\n\n### Retrieving relations\n\nCurrently, aliases and general relations are supported:\n\n    from crossref_commons.relations import get_related\n\n    get_related('10.1167/18.8.6')\n\n### Iterating\n\nIt is possible to iterate over publications meeting specific criteria (JSON only):\n\n    from crossref_commons.iteration import iterate_publications_as_json\n\n    filter = {'funder': '10.13039/501100000038', 'type': 'journal-article'}\n    queries = {'query.author': 'li', 'query.affiliation': 'university'}\n    for p in iterate_publications_as_json(max_results=189, filter=filter, queries=queries):\n      print(p['DOI'])\n\n### Sampling\n\nInstead 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:\n\n    from crossref_commons.sampling import get_sample\n\n    filter = {'funder': '10.13039/501100000038', 'type': 'journal-article'}\n    queries = {'query.author': 'li', 'query.affiliation': 'university'}\n    sample = get_sample(size=121, filter=filter, queries=queries)\n\n### Authorization\n\nYou can set the Polite information and/or Plus token by creating a file `~/.crapi_key` with the following content:\n\n    {\n      \"Crossref-Plus-API-Token\": \"<<Plus API token, for Plus users only>>\",\n      \"User-Agent\": \"<<polite user agent; including mailto:email address>>\",\n      \"Mailto\": \"<<email address>>\"\n    }\n\nAlternatively, the same information can be provided through environment variables `CR_API_PLUS`, `CR_API_AGENT` and `CR_API_MAILTO`.\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Crossref Commons",
    "version": "0.0.7",
    "project_urls": {
        "Homepage": "https://gitlab.com/crossref/crossref_commons_py"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa83c4d638f2f34ef722f8e655fa86d39215f36b8607a7927af2f2ebe5434431",
                "md5": "dd34a2066e9134362480b3c00a27c95a",
                "sha256": "ab4f7a62a7745cf70ef68ffdebbb58091493db324a269f29df915f6f43bdf130"
            },
            "downloads": -1,
            "filename": "crossref_commons-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dd34a2066e9134362480b3c00a27c95a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14675,
            "upload_time": "2020-01-13T19:37:27",
            "upload_time_iso_8601": "2020-01-13T19:37:27.806779Z",
            "url": "https://files.pythonhosted.org/packages/aa/83/c4d638f2f34ef722f8e655fa86d39215f36b8607a7927af2f2ebe5434431/crossref_commons-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a9da69673e371afa0d77edcb0cc8dfb6b05ccd9e1ffe879ca7804cf32e7851c",
                "md5": "101ed74932a8837e264d988fcace51fe",
                "sha256": "4b8ae35d48acc4fe62da1662525396477e4f8c76fdb00cd42d5334c68713c4b6"
            },
            "downloads": -1,
            "filename": "crossref_commons-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "101ed74932a8837e264d988fcace51fe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8261,
            "upload_time": "2020-01-13T19:37:29",
            "upload_time_iso_8601": "2020-01-13T19:37:29.151337Z",
            "url": "https://files.pythonhosted.org/packages/8a/9d/a69673e371afa0d77edcb0cc8dfb6b05ccd9e1ffe879ca7804cf32e7851c/crossref_commons-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-01-13 19:37:29",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "crossref",
    "gitlab_project": "crossref_commons_py",
    "lcname": "crossref-commons"
}
        
Elapsed time: 2.09222s