adsfolio.client
Base HTTP client for NASA ADS with rate limiting and caching.
- class adsfolio.client.ADSClient(token=None, timeout=(3.05, 30.0))[source]
Bases:
objectHigh-level NASA ADS client.
Provides access to all API modules (Search, Export, Libraries, etc.) through a unified interface.
Examples
>>> client = ADSClient() >>> results = client.search.query("author:Einstein", rows=5) >>> bibtex = client.export.export(["2020ApJ...900..100S"], format="bibtex")
- download_pdf(bibcode, output_dir='.', link_types=None, force_print_html=False, timeout=30, printed_suffix='__printed')[source]
Download a paper PDF by ADS bibcode via link-gateway.
- Parameters:
bibcode (str) – ADS bibcode to fetch.
output_dir (str or pathlib.Path, optional) – Destination directory for downloaded/printed PDFs.
link_types (sequence of str, optional) – ADS gateway link types to try in order. Defaults to (“PUB_PDF”, “EPRINT_PDF”, “AUTHOR_PDF”).
force_print_html (bool, optional) – If True and only HTML landing pages are found, print final HTML page to PDF using Playwright as a fallback.
timeout (int, optional) – Request timeout in seconds.
printed_suffix (str, optional) – Suffix for printed fallback files. It must form a safe filename.
- Returns:
Saved PDF path on success, else None. Existing direct and printed downloads remain unchanged. A new download receives a numeric suffix when its intended filename exists.
- Return type:
pathlib.Path or None
- Raises:
ValueError – If the bibcode or printed suffix cannot form a safe filename.
Notes
Direct responses require a PDF header. An HTML error response causes the downloader to try its next source instead of saving HTML as PDF.
- download_pdfs(bibcodes, output_dir='.', link_types=None, force_print_html=False, timeout=30, printed_suffix='__printed', show_progress=True, progress_desc='Downloading ADS PDFs', progress_leave=False, max_workers=8)[source]
Download PDFs for multiple bibcodes.
- Parameters:
bibcodes (sequence of str) – Bibcodes to download.
output_dir (str or pathlib.Path, optional) – Destination directory for downloaded/printed PDFs.
link_types (sequence of str, optional) – Gateway link types to try in order.
force_print_html (bool, optional) – If True, print HTML pages when direct PDF retrieval fails.
timeout (int, optional) – Request timeout in seconds.
printed_suffix (str, optional) – Suffix for printed fallback files.
show_progress (bool, optional) – Show progress bar using tqdm when available. Default: True.
progress_desc (str, optional) – Description text for progress bar.
progress_leave (bool, optional) – Leave completed progress bar on screen.
max_workers (int, optional) – Maximum number of parallel download workers. Use 1 for serial mode. Default: 8.
- Returns:
Mapping from bibcode to downloaded file path (or None on failure).
- Return type:
dict[str, pathlib.Path | None]
- class adsfolio.client.BaseClient(token=None, timeout=(3.05, 30.0))[source]
Bases:
objectLow-level HTTP client for NASA ADS.
Handles authentication, rate limiting, and error handling.
- post_raw(endpoint, data=None, params=None, headers=None)[source]
Make a POST request with a raw payload (non-JSON body).