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.
Metadata
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| citationlib-0.2.1.tar.gz | 20.8 kB | Without provenance | Details for citationlib-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| citationlib-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for citationlib-0.2.1-py3-none-any.whl |
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
|
Security for citationlib 0.2.1
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.