adsfolio.api.export
Export API wrapper for ADS.
Provides access to bibliography export in various formats: - BibTeX, AASTeX, MNRAS, Icarus, etc. - Custom format strings
- class adsfolio.api.export.ExportAPI(client)[source]
Bases:
objectExport API for retrieving bibliographic data in various formats.
Examples
>>> api = ExportAPI(client) >>> bibtex = api.export(["2020ApJ...900..100S"], format="bibtex") >>> print(bibtex)
- Parameters:
client (BaseClient)
- BIBLIOGRAPHY_FORMATS = ('bibtex', 'bibtexabs', 'ris', 'endnote', 'aastex', 'mnras', 'icarus', 'soph', 'ads', 'procite', 'refworks', 'medlars')
- FORMATS: ClassVar[list[str]] = ['bibtex', 'bibtexabs', 'ads', 'aastex', 'icarus', 'mnras', 'soph', 'endnote', 'procite', 'ris', 'refworks', 'rss', 'medlars', 'dcxml', 'refxml', 'refabsxml', 'votable', 'custom']
- MAX_RECORDS_PER_REQUEST = 2000
- export(bibcodes, format='bibtex', sort=None, custom_format=None)[source]
Export bibcodes in the specified format.
- Parameters:
- Returns:
Exported bibliography in requested format.
- Return type:
Examples
>>> bibtex = api.export(["2020ApJ...900..100S"], format="bibtex") >>> custom = api.export(bibcodes, format="custom", ... custom_format="%R %T")
- export_complete(bibcodes, format='bibtex', *, cancelled=None)[source]
Export every requested record as one bibliography, or fail.
- Parameters:
bibcodes (sequence of str) – Unique ADS Bibcodes. The input order is preserved across batches.
format (str, optional) – A format in BIBLIOGRAPHY_FORMATS. Defaults to
bibtex. XML and custom formats require different assembly rules and are supported separately byexport().cancelled (callable, optional) – Cancellation check before and after each network request.
- Returns:
Complete bibliography. An empty input returns an empty string.
- Return type:
- Raises:
ValueError – If the format is unsupported or Bibcodes are empty or duplicated.
TypeError – If bibcodes is a string rather than a sequence of identifiers.
ADSError – If ADS returns missing, repeated, or malformed records.
concurrent.futures.CancelledError – If cancellation is requested. No partial bibliography is returned.
- export_entries(bibcodes, format='bibtexabs', *, cancelled=None, progress=None)[source]
Return one exported entry for each Bibcode that ADS knows.
- Parameters:
bibcodes (sequence of str) – ADS Bibcodes. Requests use batches of MAX_RECORDS_PER_REQUEST.
format (str, optional) – A format in BIBLIOGRAPHY_FORMATS. Defaults to
bibtexabs.cancelled (callable, optional) – Cancellation check before each network request.
progress (callable, optional) – Called with the number of requested and total Bibcodes after each batch.
- Returns:
Entry text by requested Bibcode. A Bibcode that ADS does not return is absent.
- Return type:
- Raises:
ADSError – If ADS returns a malformed response.
concurrent.futures.CancelledError – If cancellation is requested.