Skip to main content

Synchronize BibTeX files from citation keys in LaTeX sources

Project description

bibsync

CI Documentation Status Crates.io Docs.rs PyPI Version Python Versions License Ruff DOI SPEC 0 — Minimum Supported Dependencies

bibsync synchronizes BibTeX files from citation keys in LaTeX sources. It is inspired by adstex, with provider support for both NASA ADS and InspireHEP.

The primary workflow is to cite papers by identifier, especially arXiv ID:

\citep{2404.14498}
\citet{arXiv:2312.00752}

Then check the bibliography:

bibsync main.tex -o references.bib

To update the file, add --fix:

bibsync --fix main.tex -o references.bib

bibsync scans the TeX file, resolves missing identifier-like citekeys through NASA ADS and/or InspireHEP, rewrites provider BibTeX entries so the citekey stays the key used in TeX, and reports whether the output .bib file is current. With --fix, it writes the merged bibliography.

Installation

Install the Rust CLI from crates.io:

cargo install bibsync

Install the Python package from PyPI:

pip install bibsync

The PyPI package includes Python bindings and installs the bibsync command. Python 3.12 or newer is required.

You can also download a pre-built binary from the GitHub releases page. Pick the archive for your platform, extract it, and place the bibsync executable somewhere on your PATH.

To compile from source:

git clone https://github.com/isaac-cf-wong/bibsync.git
cd bibsync
cargo build --release

The compiled binary is written to target/release/bibsync on Unix-like systems or target\release\bibsync.exe on Windows.

Citing

If bibsync contributes to a scientific publication, please cite it using the Zenodo record:

https://doi.org/10.5281/zenodo.20422622

Citation formats including BibTeX can be exported directly from the Zenodo page. For convenience, you can also use:

@software{wong2026bibsync,
  author  = {Wong, Isaac C. F.},
  title   = {bibsync: A Rust package to automatically resolve, synchronize, and validate LaTeX citations across BibTeX databases},
  version = {v0.3.1},
  year    = {2026},
  month   = may,
  doi     = {10.5281/zenodo.20422622},
  url     = {https://doi.org/10.5281/zenodo.20422622}
}

Providers

By default bibsync tries NASA ADS first and InspireHEP second:

bibsync --fix main.tex -o references.bib --provider auto

NASA ADS requires an API token:

export ADS_API_TOKEN="..."

You can choose a single provider:

bibsync --fix main.tex -o references.bib --provider ads
bibsync --fix main.tex -o references.bib --provider inspire

InspireHEP supports arXiv IDs and DOIs. NASA ADS supports arXiv IDs, DOIs, and ADS bibcodes.

Python API

bibsync can also be installed from PyPI:

pip install bibsync

The PyPI package provides Python bindings backed by the Rust implementation:

import bibsync

report = bibsync.sync_files(
    ["main.tex"],
    output="references.bib",
    provider="inspire",
    check=True,
)

It also installs the bibsync command. The command delegates to the same Rust CLI implementation as the Cargo-installed binary, so command-line behavior is kept in one place.

Existing Bibliographies

If the TeX source contains \bibliography{references}, bibsync can discover references.bib automatically:

bibsync --fix main.tex

Additional read-only bibliographies can be used to avoid duplicating entries:

bibsync --fix main.tex -o references.bib -r shared.bib software.bib

Use --merge-other to copy matching entries from those read-only files into the main output file.

To update a bibliography in place, pass a single .bib file:

bibsync --fix references.bib --force-regenerate

Update Behavior

By default bibsync leaves published entries untouched. Only entries that look like unpublished preprints — those with an archivePrefix or eprinttype field but no journal field — are re-queried to check whether they have been published. If so, the entry is updated; otherwise it is preserved.

Flag Behavior
(default) Re-check preprints; skip published entries
--no-update Skip all existing entries
--update-all Re-resolve all existing entries
--force-regenerate Re-resolve and overwrite all existing entries

Ignoring Entries

To exclude specific entries from all resolution — for example, books or theses you have curated by hand — list their citekeys in a .bibsyncignore file:

# .bibsyncignore
knuth1997art
smith2024thesis

Pass the file with --ignore-file:

bibsync --fix main.tex -o references.bib --ignore-file .bibsyncignore

Cache

Use --cache to avoid repeated provider API calls:

bibsync --cache main.tex -o references.bib
bibsync --fix --cache main.tex -o references.bib

The cache stores provider records and mappings from arXiv IDs or DOIs to the provider's canonical record ID. Preprint entries that are re-checked for publication always bypass the cache and fetch a fresh result, then write it back. Use --refresh-cache to force a fresh fetch for all entries:

bibsync --fix --refresh-cache main.tex -o references.bib

Override the cache location with --cache-dir DIR.

Pre-commit

The repository includes .pre-commit-hooks.yaml, so other projects can use bibsync as a pre-commit hook.

Use the pre-built binary hook for faster installs:

repos:
    - repo: https://github.com/isaac-cf-wong/bibsync
      rev: v0.3.1
      hooks:
          - id: bibsync-bin
            args: [--cache, --provider, inspire, --output, references.bib]

The binary hook downloads a platform-specific archive from the GitHub release matching rev and caches it under pre-commit's cache directory. The source hook is available for Linux x86_64/aarch64, macOS x86_64/aarch64, and Windows x86_64. The source hook is still available, but it compiles the Rust crate during hook installation:

repos:
    - repo: https://github.com/isaac-cf-wong/bibsync
      rev: v0.3.1
      hooks:
          - id: bibsync
            args: [--provider, inspire, --output, references.bib]

By default, the hook checks whether the bibliography is current and fails without writing changes. To let the hook update files, add --fix to the hook args:

repos:
    - repo: https://github.com/isaac-cf-wong/bibsync
      rev: v0.3.1
      hooks:
          - id: bibsync-bin
            args: [--fix, --cache, --provider, inspire, --output, references.bib]

To skip manually curated entries, add --ignore-file:

repos:
    - repo: https://github.com/isaac-cf-wong/bibsync
      rev: v0.3.1
      hooks:
          - id: bibsync-bin
            args:
                [
                    --fix,
                    --cache,
                    --provider,
                    inspire,
                    --output,
                    references.bib,
                    --ignore-file,
                    .bibsyncignore,
                ]

For a project-local hook while developing bibsync itself:

repos:
    - repo: local
      hooks:
          - id: bibsync
            name: bibsync
            entry: cargo run -- --fix --provider inspire --output references.bib
            language: system
            files: \.tex$

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

bibsync-0.3.1.tar.gz (67.4 kB view details)

Uploaded Source

Built Distributions

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

bibsync-0.3.1-cp312-abi3-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.12+Windows x86-64

bibsync-0.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

bibsync-0.3.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

bibsync-0.3.1-cp312-abi3-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

bibsync-0.3.1-cp312-abi3-macosx_10_12_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: bibsync-0.3.1.tar.gz
  • Upload date:
  • Size: 67.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bibsync-0.3.1.tar.gz
Algorithm Hash digest
SHA256 1ed07c5563355b827f32a7dd268d4221f8c43548247f8df7e7d9a93faa8ebbee
MD5 ee1bc2731f20f0d09d0d085685384a2e
BLAKE2b-256 d28916d219714a9458bc96ec7e0625400df7695b112119e55b3fbd7b62f1f26c

See more details on using hashes here.

File details

Details for the file bibsync-0.3.1-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: bibsync-0.3.1-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bibsync-0.3.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5954f66bb57ce3bea0e49fdcfff30469c9c45f23f0f42e26ddcef63efb45d51d
MD5 ea196667c73eeb1787d354bde3a1c126
BLAKE2b-256 484340bdf0ce39384838f47d41f8b20bf0ae6bb36bcdeb2d4f203d582eb8872d

See more details on using hashes here.

File details

Details for the file bibsync-0.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: bibsync-0.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bibsync-0.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 82183ae1608c9791738687bb012413eab0670e5c64348fa64e6618ffd3810188
MD5 8b68a32feac3c06b9810bce332ea18ad
BLAKE2b-256 8e8c11080845d80a96c8244b55339858cafb13aef090ca262bb8472bf56f7f8a

See more details on using hashes here.

File details

Details for the file bibsync-0.3.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: bibsync-0.3.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bibsync-0.3.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 21db84fbade20e1c71b204f16807809c08f23cce627f04830119549d476ada8f
MD5 fd861105b7180e32cc6a201a9d8da031
BLAKE2b-256 608601e2800b987e79e5498e0d8c6e20f125c27c828427631c2043cfdf95b3f2

See more details on using hashes here.

File details

Details for the file bibsync-0.3.1-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: bibsync-0.3.1-cp312-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.12+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bibsync-0.3.1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3036b777a816d35c0a683cc1b7e1b761838d6ed37b8154c1190897d809a7d51b
MD5 36293e5a7a890008693ec94bf5534762
BLAKE2b-256 35a6be831282e080da10b407e7c2c191a52138312b35f94a70de199c769c567b

See more details on using hashes here.

File details

Details for the file bibsync-0.3.1-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: bibsync-0.3.1-cp312-abi3-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.12+, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bibsync-0.3.1-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9b6d27dcd597daab65dee9336af17c403d12fbee4636c5c47463548e864b24c5
MD5 99f78fc49bb00756557fa441980400bf
BLAKE2b-256 0ee236117b4679ee3d6f042c9511df0a30c0d19d9c5009ece710952dfbb921c5

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