Skip to main content

Fetch BibTeX from DOI, or resolve arXiv IDs to DOI and fetch BibTeX

Project description

doi2bib3

doi2bib3 is a small Python utility to fetch BibTeX metadata for a DOI or to resolve arXiv identifiers to DOIs and fetch their BibTeX entries. It accepts DOI inputs, DOI URLs, arXiv IDs/URLs (modern and legacy), publisher landing pages, and uses a sequence of resolution strategies to return a BibTeX string. This tool combines the features of doi2bib and doi2bib2.

It will be submitted to PyPI soon.

Key behaviors

  • Provides bibtex entry for DOI and arXiv links.
  • Automatically detects arXiv inputs (e.g. 2411.08091, arXiv:2411.08091, or https://arxiv.org/abs/2411.08091) and queries the arXiv API for a DOI.
  • For non-arXiv inputs: attempts DOI normalization, content negotiation at doi.org, Crossref transform, and as a last resort a Crossref bibliographic search.

A GUI frontend is available: Check out QuickBib.

Installation

Create a virtual environment and install runtime dependencies:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Install the package for local development:

pip install -e .
Packaging status

Arch Linux

In Arch Linux you can install it from the AUR with the command yay -S doi2bib3.

Ubuntu

You can use our official PPA

sudo add-apt-repository ppa:apandada1/quickbib
sudo apt update
sudo apt install python3-doi2bib3

CLI usage

The CLI accepts a single positional identifier and an optional -o/--out path to save the BibTeX output. When installed, the package installs a console script named doi2bib3 (configured in pyproject.toml). From the repository root you can also run the provided main.py shim.

# using the local shim
python main.py <identifier> [-o OUT]

# or when installed as console script
doi2bib3 <identifier> -o references.bib

Examples

Fetch by DOI (bare DOI or DOI URL):

doi2bib3 10.1038/nphys1170
doi2bib3 https://doi.org/10.1038/nphys1170

ArXiv inputs (detected automatically):

doi2bib3 https://arxiv.org/abs/2411.08091
doi2bib3 arXiv:2411.08091
doi2bib3 2411.08091
doi2bib3 hep-th/9901001

Save to a file:

doi2bib3 https://doi.org/10.1038/nphys1170 -o paper.bib

Note: If the tool is not installed, you can run it with python main.py https://doi.org/10.1038/nphys1170 and so on.

Programmatic usage

The package exposes a small programmatic API so you can use doi2bib3 from Python code. The most convenient entry point is the package-level fetch_bibtex function which mirrors the CLI behavior and returns normalized BibTeX by default:

from doi2bib3 import fetch_bibtex

# Get normalized BibTeX (default)
bib = fetch_bibtex('https://www.pnas.org/doi/10.1073/pnas.2305943120')
print(bib)

# Get the raw provider output without normalization
raw = fetch_bibtex('10.1073/pnas.2305943120', normalize=False)

You can also invoke the thin CLI wrapper from utils when writing tests or automation:

from doi2bib3.utils import cli_doi2bib3
cli_doi2bib3(['https://arxiv.org/abs/2411.08091', '--out', 'paper.bib'])

License

This project is distributed under the GNU General Public License v3 (GPL-3.0-only).

Acknowledgements

Parts of the code and documentation were assisted by copilot.

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

doi2bib3-0.3.1.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

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

doi2bib3-0.3.1-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file doi2bib3-0.3.1.tar.gz.

File metadata

  • Download URL: doi2bib3-0.3.1.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for doi2bib3-0.3.1.tar.gz
Algorithm Hash digest
SHA256 5f7b1359922956a484dc3cb28ae8eb9c954219d501a1572787f4f78474525c26
MD5 545c0bcac6da0a735ae4682b71c25b4e
BLAKE2b-256 ced64e8178d93819db00a157cf968ab77a65949606d2f3b49b05efc2e449a1b0

See more details on using hashes here.

File details

Details for the file doi2bib3-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: doi2bib3-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for doi2bib3-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad06728806d59466e9f4e1fe48cce5e4ec603f910bb19a16c038db67d4494530
MD5 5a799da005452ef30edd3df496f598cd
BLAKE2b-256 b86f65aa57114505d96d316c49a117bdf540b4ecb5fb2eeae0165465bd119a29

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