Skip to content

Mxade/doibib

Repository files navigation

doibib

Convert DOIs to BibTeX format. Works with multiple citation styles (GOST, APA, Chicago, IEEE, and standard BibTeX). Handy when you need to quickly generate bibliographic references without manually typing everything.

What it does

Takes DOIs (Digital Object Identifiers) and fetches all the metadata from Crossref, then formats it as BibTeX entries. You can also get plain text citations ready to copy-paste. Supports different citation styles so you can match whatever format your journal or institution requires.

Features

  • Multiple ways to input DOIs: command line, text files, CSV, or pipe from other commands
  • Different citation styles: standard BibTeX, GOST (Russian), APA, Chicago, and IEEE
  • Fetches metadata automatically from Crossref
  • Handles multiple DOIs at once with progress tracking
  • Skips invalid DOIs and keeps going
  • Can generate both BibTeX and plain text citations

Installation

You'll need Python 3.8 or higher. If you don't have pip, install it first.

Quick setup

  1. Navigate to the directory:
cd doibib
  1. Install the required package:
pip install -r requirements.txt

That's it. The only dependency is habanero which talks to the Crossref API.

Usage

Basic stuff

Convert a single DOI:

python doi_to_bibtex.py 10.1016/j.jaip.2022.05.023

Multiple DOIs at once:

python doi_to_bibtex.py 10.1016/j.jaip.2022.05.023 10.1007/s00421-018-3910-3

Citation styles

Different journals want different formats. Here's how to use each style:

GOST (for Russian publications):

python doi_to_bibtex.py --style gost 10.1016/j.jaip.2022.05.023

APA:

python doi_to_bibtex.py --style apa 10.1016/j.jaip.2022.05.023

Chicago:

python doi_to_bibtex.py --style chicago 10.1016/j.jaip.2022.05.023

IEEE:

python doi_to_bibtex.py --style ieee 10.1016/j.jaip.2022.05.023

Reading from files

If you have a bunch of DOIs in a text file (one per line):

python doi_to_bibtex.py --file dois.txt

From a CSV file:

python doi_to_bibtex.py --csv papers.csv --doi-column DOI

You can also pipe DOIs in:

echo "10.1016/j.jaip.2022.05.023" | python doi_to_bibtex.py --stdin

or:

cat dois.txt | python doi_to_bibtex.py --stdin

Saving output

Save to a file:

python doi_to_bibtex.py 10.1016/j.jaip.2022.05.023 --output references.bib

Plain text citations

Sometimes you just need a citation to paste into a document or email. Use --text-output:

python doi_to_bibtex.py 10.1016/j.jaip.2022.05.023 --style apa --output refs.bib --text-output refs.txt

This creates both a BibTeX file and a text file with formatted citations you can copy-paste directly.

Quiet mode

If you don't want to see progress messages:

python doi_to_bibtex.py --quiet 10.1016/j.jaip.2022.05.023

Command line options

positional arguments:
  dois                  DOIs to convert (URLs or plain DOIs both work)

optional arguments:
  -h, --help            Show help
  --file FILE, -f FILE  Read DOIs from a text file (one per line)
  --csv CSV             Read DOIs from a CSV file
  --stdin               Read DOIs from standard input
  --doi-column COLUMN   Column name in CSV containing DOIs (default: DOI)
  --style STYLE, -s STYLE
                        Citation style: standard, gost, apa, chicago, ieee
                        (default: standard)
  --output OUTPUT, -o OUTPUT
                        Output BibTeX file (default: prints to stdout)
  --text-output TEXT_OUTPUT, -t TEXT_OUTPUT
                        Also create a plain text file with formatted citations
  --delay DELAY         Seconds to wait between API requests (default: 0.5)
  --quiet, -q           Don't show progress messages

Citation styles explained

Standard BibTeX

Default format. Works with most LaTeX setups.

Author format: Last, First and Last, First

GOST (Russian Standard)

For Russian academic publications. Follows ГОСТ 7.0.5-2008.

Author format: Фамилия, И. О. and Фамилия, И. О. (initials after last name)

APA

American Psychological Association style.

Author format: Last, F. M. and Last, F. M. (initials)

Chicago

Chicago Manual of Style.

Author format: Last, First Middle and Last, First Middle (full names)

IEEE

Institute of Electrical and Electronics Engineers style.

Author format: F. M. Last and F. M. Last (initials before last name - this one's different!)

Examples

Example 1: Batch processing

Create a file dois.txt with your DOIs:

10.1016/j.jaip.2022.05.023
10.1007/s00421-018-3910-3
10.1111/dom.12821

Then run:

python doi_to_bibtex.py --file dois.txt --output references.bib

Example 2: CSV input

If you have a CSV file papers.csv:

Title,DOI,Year
Paper 1,10.1016/j.jaip.2022.05.023,2022
Paper 2,10.1007/s00421-018-3910-3,2018

Run:

python doi_to_bibtex.py --csv papers.csv --doi-column DOI --output references.bib

Example 3: Russian publication

For GOST style:

python doi_to_bibtex.py --style gost --file dois.txt --output references_gost.bib

Example 4: Both BibTeX and text

Generate both formats at once:

python doi_to_bibtex.py --file dois.txt --style apa --output refs.bib --text-output refs.txt

You'll get:

  • refs.bib - BibTeX for LaTeX
  • refs.txt - Plain text citations ready to copy-paste

DOI formats

The tool accepts DOIs in different formats:

  • Plain: 10.1016/j.jaip.2022.05.023
  • URL: https://doi.org/10.1016/j.jaip.2022.05.023
  • With quotes: "10.1016/j.jaip.2022.05.023"

All get normalized automatically, so don't worry about the format.

Error handling

  • Invalid DOIs get skipped (with a warning)
  • If Crossref API is down, it'll tell you which DOIs failed
  • Missing metadata? It'll still generate what it can

Rate limiting

By default there's a 0.5 second delay between API requests to be nice to Crossref. You can change it:

python doi_to_bibtex.py --delay 1.0 10.1016/j.jaip.2022.05.023

Project structure

doibib/
├── doi_to_bibtex.py      # Main script
├── requirements.txt      # Dependencies
├── README.md            # This file
├── README_ru.md         # Russian docs
├── utils/               # Helper modules
│   ├── doi.py           # DOI normalization
│   ├── crossref.py      # Crossref API stuff
│   └── authors.py       # Author name formatting
└── styles/              # Citation style formatters
    ├── standard.py
    ├── gost.py
    ├── apa.py
    ├── chicago.py
    └── ieee.py

Contributing

Found a bug? Want to add a feature? Pull requests welcome. You can also:

  • Report issues
  • Suggest new citation styles
  • Improve docs
  • Add features

License

Open source. Use it for academic/research work.

Credits

Support

Questions or problems? Open an issue on the repo.


Note: This is for academic/research use. Be nice to the Crossref API - don't hammer it with thousands of requests at once. The default rate limiting should help, but use your judgment.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages