Skip to main content

CitationLib

A powerful Python library for generating academic citations from various sources including DOIs, arXiv papers, PubMed articles, and web pages. The library supports multiple citation styles and output formats.

Features

  • Multiple Citation Styles

    • APA (7th edition)
    • MLA (9th edition)
    • Chicago (17th edition)
  • Various Output Formats

    • Plain text
    • HTML
    • Markdown
    • LaTeX
    • BibTeX
  • Source Support

    • DOI (Digital Object Identifier)
    • arXiv papers
    • PubMed articles
    • PMC articles
    • General web pages
    • News articles

Installation

pip install citationlib

Quick Start

from citationlib import create_citation, Style, Format

# Basic usage - defaults to APA style and plain text format
citation = create_citation("https://doi.org/10.1038/s41586-021-03819-2")
print(citation)

# Using different citation styles
mla_citation = create_citation(
    "https://arxiv.org/abs/2303.08774",
    style=Style.MLA
)
print(mla_citation)

# Different output formats
latex_citation = create_citation(
    "https://www.nature.com/articles/s41586-021-03819-2",
    style=Style.CHICAGO,
    output_format=Format.LATEX
)
print(latex_citation)

# BibTeX output
bibtex_entry = create_citation(
    "https://arxiv.org/abs/1706.03762",
    output_format=Format.BIBTEX
)
print(bibtex_entry)

Detailed Usage

Citation Styles

The library supports three major citation styles:

from citationlib import create_citation, Style

# APA (7th edition)
apa_citation = create_citation(url, style=Style.APA)

# MLA (9th edition)
mla_citation = create_citation(url, style=Style.MLA)

# Chicago (17th edition)
chicago_citation = create_citation(url, style=Style.CHICAGO)

Output Formats

Choose from five different output formats:

from citationlib import create_citation, Format

# Plain text (default)
text_citation = create_citation(url, output_format=Format.PLAIN)

# HTML
html_citation = create_citation(url, output_format=Format.HTML)

# Markdown
md_citation = create_citation(url, output_format=Format.MARKDOWN)

# LaTeX
latex_citation = create_citation(url, output_format=Format.LATEX)

# BibTeX
bibtex_citation = create_citation(url, output_format=Format.BIBTEX)

Example with Different Sources

The library supports various types of academic sources:

# Academic paper from Nature
doi_citation = create_citation("https://doi.org/10.1038/s41586-021-03819-2")

# ArXiv preprint
arxiv_citation = create_citation("https://arxiv.org/abs/1706.03762")

# News article
news_citation = create_citation("https://www.theguardian.com/us-news/2025/feb/09/democrats-aggressive-stand-against-trump")

# Research website
website_citation = create_citation("https://research.google/pubs/fairness-and-optimality-in-routing/")

Error Handling

The library provides proper error handling for various scenarios:

from citationlib import create_citation

try:
    citation = create_citation("https://example.com/invalid-paper")
except Exception as e:
    print(f"Failed to create citation: {e}")

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Release files for citationlib 0.2.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 citationlib 0.2.1
File Size Uploaded
citationlib-0.2.1.tar.gz 20.8 kB Details

Built distribution (wheel)

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

Total release size: 45.2 kB

Release files / citationlib-0.2.1.tar.gz

Download URL citationlib-0.2.1.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
103dadfa56fe7ba486556bc0d938b22491a2ac0573933aa7337a0a895a200ce1
BLAKE2b-256 checksum
How to use checksums
75bf1cba03581e727f78f2316c891b785c76f2904ff61411e7ed36e38a4a5b02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / citationlib-0.2.1-py3-none-any.whl

Download URL citationlib-0.2.1-py3-none-any.whl
Size 24.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ac99c37192ade7f5628de5f38c267db290a171e43f4ce787715a938d810938d
BLAKE2b-256 checksum
How to use checksums
cdba4768d799c66f719f797dcb78990380f613b7df77ba92322eba9171b636c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

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