Skip to main content

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, DSpace 7 thesis URLs, and uses a sequence of resolution strategies to return a BibTeX string. This tool combines the features of doi2bib and doi2bib2.

Key behaviors

  • Accepts DOI, DOI URL, arXiv ID/URL, publisher URL, DSpace 7 thesis URL, or article-title text.
  • Resolves inputs to a DOI using URL metadata, arXiv metadata, Crossref lookup, and DOI content negotiation with Crossref fallback.
  • Normalizes BibTeX output, including journal abbreviation mappings and selected publisher-specific cleanup.
  • Full pipeline documentation (input -> output): docs/ALGORITHM.md
  • Diagram version of the pipeline: docs/ALGORITHM_VISUALS.md

A cross-platform GUI frontend is available: Check out QuickBib and its webapp. An Omarchy plugin is also available.

Installation

Packaging status

PyPI - Version

Install from pypi

pip install --user doi2bib3

Arch Linux

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

Ubuntu

You can use our official PPA

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

Debian

You can grab the prebuild .deb package from GitHub releases.

Termux

First install python with pkg install python and then install from pip.

Installing from source

Create a virtual environment and install runtime dependencies:

git clone https://github.com/archisman-panigrahi/doi2bib3.git
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Install the package for local development:

pip install -e .

CLI usage

The CLI accepts a single positional identifier (or -i/--input with a text file of identifiers, one per line), an optional -o/--out (alias --output) path to save the BibTeX output, and -b/--bibitem to also print an APS/RevTeX-style \bibitem. Add -m/--mbox to wrap author surnames in \mbox{} and prevent line breaks in both outputs; wrapping is disabled by default. When installed, the package installs a console script named doi2bib3 (configured in pyproject.toml). From the repository root you can run the local script wrapper at scripts/doi2bib3.

# using the local wrapper script from repo root
python scripts/doi2bib3 <identifier> [-o OUT] [--bibitem] [--mbox]

# or when installed as console script
doi2bib3 <identifier> [-o OUT] [--bibitem] [--mbox]
doi2bib3 -i IDENTIFIERS.txt [-o OUT] [--bibitem] [--mbox]

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.org/abs/2411.08091
doi2bib3 www.arxiv.org/abs/2411.08091
doi2bib3 http://xxx.lanl.gov/abs/cond-mat/9903064
doi2bib3 arXiv:2411.08091
doi2bib3 2411.08091
doi2bib3 hep-th/9901001

Name of the paper (includes fuzzy search):

doi2bib3 "Projected Topological Branes"

Publisher/article pages (Supports APS, AIP, AMS, ACS, Science, IOP Science, Nature, PNAS, SciPost, and ScienceDirect journals):

doi2bib3 https://www.pnas.org/doi/10.1073/pnas.2305943120
doi2bib3 https://pubs.aip.org/aip/rsi/article/89/10/101101/364406/Invited-Review-Article-Multi-tip-scanning
doi2bib3 https://iopscience.iop.org/article/10.1088/1402-4896/ad995f/pdf
doi2bib3 https://www.scipost.org/SciPostPhys.20.3.082/
doi2bib3 https://www.scipost.org/SciPostPhys.20.3.082/pdf
doi2bib3 https://www.sciencedirect.com/science/article/pii/S0003491605000096?via%3Dihub

Save to a file:

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

This appends the BibTeX entry to paper.bib and prints Wrote paper.bib.

Batch mode: read identifiers from a text file, one per line (blank lines and lines starting with # are ignored):

doi2bib3 --input file_with_dois.txt --output refs.bib

Failed identifiers are reported and skipped, and the exit code is 1 if any failed.

Print BibTeX and an APS/RevTeX-style \bibitem without saving to a file:

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

Save BibTeX to a file and print the \bibitem:

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

When -o/--out and --bibitem are used together, the BibTeX entry is appended to the file, Wrote paper.bib is printed, and the \bibitem is printed to the terminal. The \bibitem is not written to the .bib file.

Note: If the tool is not installed, you can run python scripts/doi2bib3 https://doi.org/10.1038/nphys1170.

Supported journal groups

doi2bib3 directly supports many APS, AMS, ACS, Nature, Science, PNAS, SciPost, ScienceDirect, AIP and IOP groups of journals. For other journals, the DOI link works, but the paper's URL would not work.

Programmatic usage

Public API

The Python API exposes one primary function:

  • doi2bib3.fetch_bibtex(identifier: str, timeout: int = 15, mbox: bool = False) -> str

Set mbox=True to opt into surname wrapping in the Python API.

Example:

from doi2bib3 import fetch_bibtex

bib = fetch_bibtex('https://www.pnas.org/doi/10.1073/pnas.2305943120')
print(bib)

Additionally two convenience helpers are provided for APS/RevTeX-style \bibitem output:

  • doi2bib3.format_bibtex_to_aps_bibitem(bibtex_str: str, key: Optional[str] = None, mbox: bool = False) -> str
  • doi2bib3.fetch_bibitem_aps(identifier: str, key: Optional[str] = None, timeout: int = 15, mbox: bool = False) -> str

Examples:

Format an already-obtained BibTeX string into an APS \bibitem:

from doi2bib3 import format_bibtex_to_aps_bibitem

normalized_bibtex = "@article{smith_foobar_2020, title={Foo Bar}, author={Smith, A.}, year={2020}}"
bibitem = format_bibtex_to_aps_bibitem(normalized_bibtex, key="Smith2020")
print(bibitem)

Fetch an identifier (DOI/arXiv/etc.), get its normalized BibTeX, and return an APS \bibitem in one call:

from doi2bib3 import fetch_bibitem_aps

bibitem = fetch_bibitem_aps('10.1038/nphys1170', key='PhysRevSmith2008')
print(bibitem)

Programmatic CLI entry

Use subprocess with scripts/doi2bib3 (or installed doi2bib3 command) for automated CLI tests.

Internal module layout

  • doi2bib3/backend.py: input resolution and network fetch logic
  • doi2bib3/normalize.py: BibTeX normalization/transforms
  • doi2bib3/io.py: file output helpers
  • scripts/doi2bib3: command-line argument parsing and output handling

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 and codex.

Future plans

Fix common pitfals listed in https://tex.stackexchange.com/q/386053/78560. This is tracked in todo.md.

Metadata

Release files for doi2bib3 1.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for doi2bib3 1.8.1
File Size Uploaded Provenance Actions
doi2bib3-1.8.1.tar.gz 55.7 kB Without provenance Details for doi2bib3-1.8.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for doi2bib3 1.8.1
File Interpreter ABI Platform Actions
doi2bib3-1.8.1-py3-none-any.whl Python 3 none any Details for doi2bib3-1.8.1-py3-none-any.whl

Total release size: 97.6 kB

Release files / doi2bib3-1.8.1.tar.gz

Download URL doi2bib3-1.8.1.tar.gz
Size 55.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7c17db180a00e33162730800fd8e8c93842ca0da71478dc681481bd92a7f20de
BLAKE2b-256 checksum
How to use checksums
b009a6b12411cd15e941616febeaf90ca7e31ed10144bb9778d409e49c88db35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / doi2bib3-1.8.1-py3-none-any.whl

Download URL doi2bib3-1.8.1-py3-none-any.whl
Size 41.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7fc1dd96d5d469280fc3f39354fdcc2f6f2a66dd01454927b00dd7c60e6df64
BLAKE2b-256 checksum
How to use checksums
782bc1548617d1178e9ef78d4d0e066ed69d2fabd930b37c6b6fe3bfe586ac1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for doi2bib3 1.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.8.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page