Skip to main content

Low Level Client for Crossref Search API

Project description

habanero

pypi Docs ghactions coverage Ruff uv

This is a low level client for working with Crossref’s search API. It’s been named to be more generic, as other organizations are/will adopt Crossref’s search API, making it possible to interact with all from one client.

Crossref API docs

Other Crossref API clients:

Crossref’s API issue tracker: https://crossref.atlassian.net/jira/software/c/projects/CR/issues/

habanero includes three modules you can import as needed (or import all):

Crossref - Crossref search API. The Crossref module includes methods matching Crossref API routes, and a few convenience methods for getting DOI agency and random DOIs:

  • works - /works route

  • members - /members route

  • prefixes - /prefixes route

  • funders - /funders route

  • journals - /journals route

  • types - /types route

  • licenses - /licenses route

  • registration_agency - get DOI minting agency

  • random_dois - get random set of DOIs

counts - citation counts. Includes the single citation_count method

cn - content negotiation. Includes the methods:

  • content_negotiation - get citations in a variety of formats

  • csl_styles - get CSL styles, used in content_negotation method

WorksContainer - A class for handling Crossref works. Pass output of works from methods on the Crossref class to more easily extract specific fields of works.

Note about searching:

You are using the Crossref search API described at https://api.crossref.org/swagger-ui/index.html. When you search with query terms, on Crossref servers they are not searching full text, or even abstracts of articles, but only what is available in the data that is returned to you. That is, they search article titles, authors, etc. For some discussion on this, see https://gitlab.com/crossref/issues/-/issues/101

Rate limits

See the headers X-Rate-Limit-Limit and X-Rate-Limit-Interval for current rate limits.

The Polite Pool

To get in the polite pool it’s a good idea now to include a mailto email address. See docs for more information.

Installation

Stable version

# pip
pip install habanero

# uv w/ legacy project setup
uv pip install habanero
# uv w/ pyproject.toml
uv add habanero

If you would like to fix bibtex format citations using content negotiation you’ll have to install the optional dependency bibtexparser >= 2.0.0b7 (done for you with optional [bibtex])

pip install habanero[bibtex]

Dev version

pip install git+https://github.com/sckott/habanero.git#egg=habanero

Or build it yourself locally

git clone https://github.com/sckott/habanero.git
cd habanero
make install

Usage

Initialize a client

from habanero import Crossref
cr = Crossref()

Works route

# query
x = cr.works(query = "ecology")
x['message']
x['message']['total-results']
x['message']['items']

# fetch data by DOI
cr.works(ids = '10.1371/journal.pone.0033693')

Members route

# ids here is the Crossref Member ID; 98 = Hindawi
cr.members(ids = 98, works = True)

Citation counts

from habanero import counts
counts.citation_count(doi = "10.1016/j.fbr.2012.01.001")

Content negotiation - get citations in many formats

from habanero import cn
cn.content_negotiation(ids = '10.1126/science.169.3946.635')
cn.content_negotiation(ids = '10.1126/science.169.3946.635', format = "citeproc-json")
cn.content_negotiation(ids = "10.1126/science.169.3946.635", format = "rdf-xml")
cn.content_negotiation(ids = "10.1126/science.169.3946.635", format = "text")
cn.content_negotiation(ids = "10.1126/science.169.3946.635", format = "text", style = "apa")
cn.content_negotiation(ids = "10.1126/science.169.3946.635", format = "bibentry")

Meta

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

habanero-2.3.0.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

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

habanero-2.3.0-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file habanero-2.3.0.tar.gz.

File metadata

  • Download URL: habanero-2.3.0.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for habanero-2.3.0.tar.gz
Algorithm Hash digest
SHA256 871e5d088ef641b05514d44b004af512852b309bcd0d81f10545e58d54a654ab
MD5 415d0e17fa21438d14cac52297760c28
BLAKE2b-256 7e79e1463d0829f1b9d9a140ea78dda9461c13a8d9589797ab1ff5b7fffd133f

See more details on using hashes here.

Provenance

The following attestation bundles were made for habanero-2.3.0.tar.gz:

Publisher: publish.yml on sckott/habanero

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file habanero-2.3.0-py3-none-any.whl.

File metadata

  • Download URL: habanero-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for habanero-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba44dd33d562ff33bd778fd7f94bfac3bf805b0b0963976f379e0a1d6894329e
MD5 ff5d196c1a1135ae8214f7276330e351
BLAKE2b-256 a9763e7d4c17024e70b1be20623937bde945842480b84d6f7dd49bd0ef372d84

See more details on using hashes here.

Provenance

The following attestation bundles were made for habanero-2.3.0-py3-none-any.whl:

Publisher: publish.yml on sckott/habanero

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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