Start-up

You initalize sprynger as follows:

>>> import sprynger

>>> # Use a single API key (for backward compatibility)
>>> sprynger.init(api_key='your key')

>>> # Or use separate keys for Meta and OpenAccess APIs
>>> sprynger.init(api_key_meta='your_meta_key', api_key_oa='your_openaccess_key')

This reads your api key(s) and uses the default configuration. You can also define environment variables: API_KEY (for both APIs), API_KEY_META (for Meta API), or API_KEY_OA (for OpenAccess API). To use a custom configuration specify config_file in init().

init(api_key: str | None = None, api_key_meta: str | None = None, api_key_oa: str | None = None, config_file: str | Path | None = None) None

Function to initialize the sprynger library. For more information go to the documentation.

Parameters:
  • api_key (str, optional) – API key (for backward compatibility, will be used for both Meta and OpenAccess)

  • api_key_meta (str, optional) – API key for Meta API

  • api_key_oa (str, optional) – API key for OpenAccess API

  • config_file (str or Path, optional) – Path to the configuration .toml file.

Raises:

ValueError – If no API key was provided either as an argument or as environment variables (API_KEY, API_KEY_META, or API_KEY_OA).

Example:

from sprynger import init
# Use a single key for both APIs
init(api_key='your key')
# Use separate keys
init(api_key_meta='your_meta_key', api_key_oa='your_openaccess_key')
# Use a custom configuration file
init(api_key='your key', config_file='path/to/custom/config.toml')

In case you don’t have a configuration file just enter your API key when prompted.

Note

Springer Nature API Changes: Springer Nature has changed its authentication system. Users now receive separate API keys for the Meta and OpenAccess APIs. The Metadata API is being discontinued. Use the Meta API instead for versioned metadata.

  • If you have a single key that works for both APIs, use api_key='your_key'

  • If you have separate keys, use api_key_meta='meta_key' and api_key_oa='oa_key'

Environment Variables: You can also set API keys via environment variables:

  • API_KEY - Used as default for both Meta and OpenAccess APIs

  • API_KEY_META - Specific key for Meta API (overrides API_KEY)

  • API_KEY_OA - Specific key for OpenAccess API (overrides API_KEY)

Configuration

The configuration file has to be a TOML file with the following structure. If any information is missing the default will be used.

[Directories]
Metadata = /Users/user/.cache/sprynger/metadata
Meta = /Users/user/.cache/sprynger/meta
OpenAccess = /Users/user/.cache/sprynger/open_access

[Requests]
Timeout = 20
Retries = 5
BackoffFactor = 2.0

Section [Directories] contains the paths where sprynger should store (cache) downloaded files. sprynger will create them if necessary.

Section [Requests] contains the default values for the requests library.