Skip to main content

Automatically fetch BibTeX entries from INSPIRE and ADS for LaTeX projects

Project description

easybib

Tests codecov

Automatically fetch BibTeX entries from INSPIRE and NASA/ADS for LaTeX projects.

easybib scans your .tex files for citation keys, looks them up on INSPIRE and/or ADS, and writes a .bib file with the results. It handles INSPIRE texkeys (e.g. Author:2020abc) and ADS bibcodes (e.g. 2016PhRvL.116f1102A).

Installation

pip install easybib

Usage

easybib /path/to/latex/project
easybib paper.tex

Pass a directory to scan all .tex files recursively, or a single .tex file. BibTeX entries are fetched and written to references.bib.

Options

Flag Description
-o, --output Output BibTeX file (default: references.bib)
-s, --preferred-source Preferred source: ads (default), inspire, or auto
-a, --max-authors Truncate author lists (default: 3, use 0 for no limit)
-l, --list-keys List found citation keys and exit (no fetching)
--fresh Ignore existing output file and start from scratch
--ads-api-key ADS API key (overrides ADS_API_KEY environment variable)
--config Path to config file (default: ~/.easybib.config)

Examples

# Scan a directory
easybib ./paper --preferred-source inspire

# Scan a single file
easybib paper.tex

# Use a custom output file
easybib ./paper -o paper.bib

# List citation keys without fetching
easybib ./paper -l

# Keep all authors
easybib ./paper -a 0

Config file

You can create a config file at ~/.easybib.config to set persistent defaults, so you don't have to pass the same flags every time:

[easybib]
output = references.bib
max-authors = 3
preferred-source = ads
ads-api-key = your-key-here

All fields are optional. CLI flags override config file values, which override the built-in defaults.

To use a config file at a different location:

easybib ./paper --config /path/to/my.config

Source selection

The --preferred-source flag controls where BibTeX entries are fetched from. The source determines which service provides the BibTeX data, regardless of the key format used in your .tex files.

  • ads (default) — Fetches BibTeX from ADS. If you use an INSPIRE-style key (e.g. Author:2020abc), easybib will cross-reference it via INSPIRE to find the corresponding ADS record, then pull the BibTeX from ADS. Falls back to INSPIRE if ADS lookup fails.
  • inspire — Fetches BibTeX from INSPIRE. Falls back to ADS if the INSPIRE lookup fails. Does not require an ADS API key unless the fallback is triggered.
  • auto — Chooses the source based on the key format: ADS bibcodes (e.g. 2016PhRvL.116f1102A) are fetched from ADS, while INSPIRE-style keys are fetched from INSPIRE. Falls back to the other source if the preferred one fails.

ADS API key

When using ADS as the source (the default), provide your API key either via the command line:

easybib ./paper --ads-api-key your-key-here

Or as an environment variable:

export ADS_API_KEY="your-key-here"

Get a key from https://ui.adsabs.harvard.edu/user/settings/token.

How it works

  1. Scans .tex files for \cite{...}, \citep{...}, \citet{...}, and related commands
  2. Filters for keys containing : (INSPIRE/ADS format)
  3. Fetches BibTeX from the preferred source, with automatic fallback
  4. Replaces citation keys to match those used in your .tex files
  5. Truncates long author lists
  6. Skips keys already present in the output file (use --fresh to override)

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

easybib-0.3.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

easybib-0.3.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file easybib-0.3.0.tar.gz.

File metadata

  • Download URL: easybib-0.3.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for easybib-0.3.0.tar.gz
Algorithm Hash digest
SHA256 54a3d12075df175e0ea46912341cc8801d6ab64e6a2c3518d92855f8edfec999
MD5 333fb2d2befcedfdee13841224730cde
BLAKE2b-256 729a0e1740980152e32d93409157353bab8f68e4f24d3e4e944db17897f64350

See more details on using hashes here.

File details

Details for the file easybib-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: easybib-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for easybib-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33792163260387166f412f5b11732a255ec2611612858bbe4f9e739801af8bbf
MD5 38e828c4b0a39ca1521cb7f55c3d0231
BLAKE2b-256 1bfc64bb9681022984f035e272c2d22bc32d358ac619c9c2c4051204aa6dbd99

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