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: object

Export 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
aastex(bibcodes, sort=None)[source]

Export in AASTeX format.

Parameters:
Return type:

str

bibtex(bibcodes, sort=None, with_abstract=False)[source]

Convenience method for BibTeX export.

Parameters:
  • bibcodes (list[str]) – List of bibcodes.

  • sort (str, optional) – Sort order.

  • with_abstract (bool, optional) – Include abstracts in output. Default: False.

Returns:

BibTeX formatted bibliography.

Return type:

str

custom(bibcodes, format_string, sort=None)[source]

Export with custom format string.

Parameters:
  • bibcodes (list[str]) – List of bibcodes.

  • format_string (str) – Custom format string using ADS format codes. Examples: “%R %T”, “%m %Y”, “%10.5N_%Y_%q_%V_%p”

  • sort (str, optional) – Sort order.

Returns:

Custom formatted output.

Return type:

str

export(bibcodes, format='bibtex', sort=None, custom_format=None)[source]

Export bibcodes in the specified format.

Parameters:
  • bibcodes (list[str]) – List of bibcodes to export.

  • format (str, optional) – Export format. Default: “bibtex”. See FORMATS for available options.

  • sort (str, optional) – Sort order, e.g., “first_author asc”.

  • custom_format (str, optional) – Custom format string (required if format=”custom”). See ADS documentation for format codes.

Returns:

Exported bibliography in requested format.

Return type:

str

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 by export().

  • cancelled (callable, optional) – Cancellation check before and after each network request.

Returns:

Complete bibliography. An empty input returns an empty string.

Return type:

str

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:

dict

Raises: