<commit_before>.. _api:

Developer Interface
===================

.. module:: internetarchive

Configuration
-------------

Certain functions of the internetarchive library require your archive.org credentials (i.e. uploading, modifying metadata, searching).
Your credentials and other configurations can be provided via a dictionary when instantiating an :class:`ArchiveSession` or :class:`Item` object, or in a config file.

The easiest way to create a config file is with the `configure <internetarchive.html#internetarchive.configure>`_ function::

    >>> from internetarchive import configure
    >>> configure('<EMAIL>', 'password')

Config files are stored in either ``$HOME/.ia`` or ``$HOME/.config/ia.ini`` by default. You can also specify your own path::


    >>> from internetarchive import configure
    >>> configure('<EMAIL>', 'password', config_file='/home/jake/.config/ia-alternate.ini')

Custom config files can be specified when instantiating an :class:`ArchiveSession` object::

    >>> from internetarchive import get_session
    >>> s = get_session(config_file='/home/jake/.config/ia-alternate.ini')

Or an :class:`Item` object::

    >>> form internetarchive import get_item
    >>> item = get_item('nasa', config_file='/home/jake/.config/ia-alternate.ini')

IA-S3 Configuration
~~~~~~~~~~~~~~~~~~~

Your IA-S3 keys are required for uploading and modifying metadata.
You can retrieve your IA-S3 keys at https://archive.org/account/s3.php.

They can be specified in your config file like so::

    [s3]
    access = mYaccEsSkEY
    secret = mYs3cREtKEy

Or, using the :class:`ArchiveSession` object::

    >>> from internetarchive import get_session
    >>> c = {'s3': {'access': 'mYaccEsSkEY', 'secret': 'mYs3cREtKEy'}}
    >>> s = get_session(config=c)
    >>> s.access_key
    'mYaccEsSkEY'

Cookie Configuration
~~~~~~~~~~~~~~~~~~~~

Your archive.org logged-in cookies are required for downloading access-restricted files that you have permissions to and retrieving information about archive.org catalog tasks.

Your cookies can be specified like so::

    [cookies]
    logged-in-user = user%40example.com<commit_msg>Fix typo "form" in import<commit_after>.. _api:

Developer Interface
===================

.. module:: internetarchive

Configuration
-------------

Certain functions of the internetarchive library require your archive.org credentials (i.e. uploading, modifying metadata, searching).
Your credentials and other configurations can be provided via a dictionary when instantiating an :class:`ArchiveSession` or :class:`Item` object, or in a config file.

The easiest way to create a config file is with the `configure <internetarchive.html#internetarchive.configure>`_ function::

    >>> from internetarchive import configure
    >>> configure('<EMAIL>', 'password')

Config files are stored in either ``$HOME/.ia`` or ``$HOME/.config/ia.ini`` by default. You can also specify your own path::


    >>> from internetarchive import configure
    >>> configure('<EMAIL>', 'password', config_file='/home/jake/.config/ia-alternate.ini')

Custom config files can be specified when instantiating an :class:`ArchiveSession` object::

    >>> from internetarchive import get_session
    >>> s = get_session(config_file='/home/jake/.config/ia-alternate.ini')

Or an :class:`Item` object::

    >>> from internetarchive import get_item
    >>> item = get_item('nasa', config_file='/home/jake/.config/ia-alternate.ini')

IA-S3 Configuration
~~~~~~~~~~~~~~~~~~~

Your IA-S3 keys are required for uploading and modifying metadata.
You can retrieve your IA-S3 keys at https://archive.org/account/s3.php.

They can be specified in your config file like so::

    [s3]
    access = mYaccEsSkEY
    secret = mYs3cREtKEy

Or, using the :class:`ArchiveSession` object::

    >>> from internetarchive import get_session
    >>> c = {'s3': {'access': 'mYaccEsSkEY', 'secret': 'mYs3cREtKEy'}}
    >>> s = get_session(config=c)
    >>> s.access_key
    'mYaccEsSkEY'

Cookie Configuration
~~~~~~~~~~~~~~~~~~~~

Your archive.org logged-in cookies are required for downloading access-restricted files that you have permissions to and retrieving information about archive.org catalog tasks.

Your cookies can be specified like so::

    [cookies]
    logged-in-user = user%40example.com
{'fraction_non_alphanumeric': 0.1390051139005114, 'fraction_numerical': 0.004649000464900047, 'mean_word_length': 4.398996235884567, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 81, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5352727', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1177, 'n_words': 415}