Skip to main content

PyPI Python License: MIT Issues Repo size

CiteMaster

CiteMaster turns research paper titles into formatted citations. It looks up each title on CrossRef, resolves the DOI, fetches the BibTeX entry and formats it in APA, MLA or IEEE style.

Features

  • Title to DOI lookup via the CrossRef API, with a title-similarity check so unrelated results are rejected
  • BibTeX retrieval for each DOI
  • APA, MLA and IEEE formatting
  • Single titles or batches from .txt / .csv files, processed concurrently
  • Command-line interface (cite-master) and an interactive mode (python -m cite_master)
  • Automatic retries for network errors and rate limits
  • On-disk cache of lookups, so repeated runs do not hit the API again
  • Titles that could not be resolved are written to failed_titles.txt

Installation

Requires Python 3.9 or newer.

pip install cite_master

From source:

git clone https://github.com/mehmoodulhaq570/CiteMaster.git
cd CiteMaster
pip install .

Command-line usage

# Cite a single title (APA by default)
cite-master "Attention Is All You Need"

# Cite every title in a file in IEEE style and also save BibTeX
cite-master examples/papers.txt --style ieee --bibtex

# Write output files to a specific directory, using 8 worker threads
cite-master papers.txt --style mla -o results/ --workers 8

# Skip the cache and use a specific config file
cite-master papers.txt --no-cache --config my_config.json

Options:

Option Description
--style {apa,mla,ieee} Citation style
--bibtex Also output the BibTeX entries
-o, --output-dir DIR Directory for output files
--config PATH Path to a JSON config file
--workers N Number of concurrent lookups for batch input
--no-cache Do not read or write the lookup cache
--quiet / --verbose Less or more console output
--version Print the version and exit

Run cite-master --help for the full list.

Exit codes: 0 every title was cited, 1 at least one title failed, 2 usage or file error (for example a missing input file).

Interactive mode

python -m cite_master

You are prompted for a title or file path, a citation style, and whether to include and save BibTeX.

Library usage

from cite_master import cite_title

result = cite_title("Attention Is All You Need", style="apa")
if result.ok:
    print(result.citation)
else:
    print(result.status, result.error)  # e.g. "doi_not_found"

cite_title returns a CitationResult with title, doi, bibtex, citation, status and error; it does not print or prompt. from cite_master import main runs the interactive program.

cite_titles (concurrent, results in input order) and read_titles handle lists of titles and title files. The lower-level helpers get_doi_from_title, fetch_bibtex_from_doi and format_citation are also exported from cite_master.

The package logs to the cite_master logger and does not configure logging itself when used as a library.

Input formats

  • .txt: one title per line (blank lines are ignored)
  • .csv: titles in the first column

See examples/papers.txt for a sample.

Output files

Written to the output directory (default outputs/):

  • citations_output.txt: formatted citations
  • bibtex_output.txt: BibTeX entries (when requested)
  • failed_titles.txt: titles that could not be cited (no DOI, no BibTeX, or an error), one per line, so the file can be fed back in to retry them

Existing files are not overwritten; a numbered name is used instead.

The CLI writes its log to citemaster.log.

Configuration

Settings are read from the first config file found:

  1. the path passed with --config
  2. ./config.json in the current directory
  3. ~/.config/citemaster/config.json

Create a file with all defaults:

python -c "from cite_master.config import Config; Config.create_default_config_file()"

Common keys:

Key Default Meaning
output_dir "outputs" Directory for output files
citations_filename "citations_output.txt" Citations file name
bibtex_filename "bibtex_output.txt" BibTeX file name
failed_filename "failed_titles.txt" File listing titles that could not be cited
api_timeout 30 Request timeout in seconds
api_retry_attempts 3 Attempts per request for network errors, 429 and 5xx (other 4xx fail at once)
api_retry_delay 1 Initial retry delay in seconds (backs off exponentially)
api_rate_limit 50 Maximum requests per minute
max_workers 4 Concurrent lookups for batch input
cache_enabled true Use the lookup cache
cache_expiry_days 30 Days before a cached entry is refreshed
cache_dir null Cache directory (default ~/.cache/citemaster/)
crossref_mailto "" Your email, sent to CrossRef for its "polite" pool
title_match_threshold 0.9 Minimum title similarity (0-1) to accept a CrossRef match
verbose / quiet false Console verbosity

Command-line options override values from the config file.

CiteMaster also follows the limits CrossRef reports in its response headers. Without crossref_mailto that is currently one request at a time and one per second, so --workers mostly speeds up cached lookups. Setting crossref_mailto puts you in CrossRef's "polite" pool, which allows more, and is recommended for large batches. See readme_docs/CONFIGURATION.md for details.

Cache

DOI and BibTeX lookups are cached under ~/.cache/citemaster/. Entries expire after cache_expiry_days. Use --no-cache (or "cache_enabled": false) to bypass it, or delete the directory to clear it.

Upgrading from 0.1.x

  • Python 3.9 or newer is required.
  • The log file is now citemaster.log (was errors.log).
  • process_file returns a list of (title, doi) tuples instead of a dict, so duplicate titles are kept and order is preserved. It no longer prints.
  • process_multiple_titles returns a list of CitationResult instead of a dict. New code should use cite_titles directly.
  • The citations file holds only successful citations; failed titles go to failed_titles.txt.

Development

pip install -e ".[test]"
pytest                    # offline unit tests
pytest -m integration     # live CrossRef tests (needs network)

See readme_docs/TESTING.md.

Changelog

See CHANGELOG.md.

Uninstalling

pip uninstall cite_master

License

MIT. See LICENSE.

Contributing

Issues and pull requests are welcome at https://github.com/mehmoodulhaq570/CiteMaster.

Acknowledgments

Metadata

Release files for cite-master 0.2.0

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

Source distribution (sdist)

Source distribution for cite-master 0.2.0
File Size Uploaded Provenance Actions
cite_master-0.2.0.tar.gz 34.0 kB Without provenance Details for cite_master-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cite-master 0.2.0
File Interpreter ABI Platform Actions
cite_master-0.2.0-py3-none-any.whl Python 3 none any Details for cite_master-0.2.0-py3-none-any.whl

Total release size: 67.2 kB

Release files / cite_master-0.2.0.tar.gz

Download URL cite_master-0.2.0.tar.gz
Size 34.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3ac4314c5377b1e0d81c78a4a03ea67bc333aa1ab6cfe8d19b899ea147fb0e77
BLAKE2b-256 checksum
How to use checksums
9d47451cdeb5eddec15462c8c3417d58e53ece041b7564c4eb317f9f2870e92c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release files / cite_master-0.2.0-py3-none-any.whl

Download URL cite_master-0.2.0-py3-none-any.whl
Size 33.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5fa478e8f23eded8d45af4a4b74bc0eb81f6fae5d83fdfa91ff2c15bff98c302
BLAKE2b-256 checksum
How to use checksums
4da4a541c5be5049514e22fe3e172eeea7ef16c5d0cd573749b195ec1cc8cadc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Security for cite-master 0.2.0

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.

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