internetarchive-ts - v0.1.0
    Preparing search index...

    Class IaSessionBeta

    The IaSession is the main class for interacting with Internet Archive API endpoints. (WaybackMachine endpoints are in the WaybackMachine class)

    It is recommended to use an instance of this class to access Internet Archive API endpoints.

    import {IaSession} from "internetarchive-ts";
    const s = new IaSession();
    const item = await getItem('nasa');
    Index

    Constructors

    Properties

    accessKey?: string
    catalog: IaCatalog
    config: IaAuthConfig
    cookies: IaCookieJar
    debug: boolean = false

    Set debug behaviour

    headers: HttpHeaders

    HTTP Headers

    host: string
    protocol: string
    secretKey?: string
    secure: boolean
    url: string
    userEmail?: string

    Methods

    • Beta

      Check identifier availability

      Parameters

      • identifier: string

        Identifier

      • findUnique: boolean = true

        TODO

      Returns Promise<string>

      identifier if identifier is available, otherwise a generated available identifier based on the input

    • Beta

      Private fetch wrapper with support for timeouts

      Parameters

      • url: string
      • options: RequestInit
      • OptionaltimeoutMs: number
      • retries: number = 0

      Returns Promise<Response>

      fetch Response

    • Beta

      Sends a GET Request

      Parameters

      • url: string

        URL to get

      • __namedParameters: {
            headers?: HttpHeaders;
            params?: Record<string, string | number | boolean | undefined>;
            timeout?: number;
        } = {}

      Returns Promise<Response>

    • Beta

      Sends a GET request to the URL and expects a JSON response in return. If the response has a non-200 status OR the response has an "error" field, an error gets thrown

      Type Parameters

      • T extends {}

        Expected return type from a successful response

      Parameters

      • url: string
      • params: {
            headers?: HttpHeaders;
            params?: Record<string, string | number | boolean | undefined>;
            timeout?: number;
        } = {}

      Returns Promise<T>

      Promise that resolved with the JSON body

      IaApiError - IaApiError If response has a non-200 status or an "error" field.

    • Beta

      Get all queued or running tasks.

      Parameters

      • params: {
            args?: string;
            catalog?: 0 | 1;
            cmd?: string;
            cursor?: string;
            history?: 0 | 1;
            identifier?: string;
            limit?: number;
            priority?: number;
            server?: string;
            submitter?: string;
            "submittime<"?: string;
            "submittime<="?: string;
            "submittime>"?: string;
            "submittime>="?: string;
            summary?: 0 | 1;
            task_id?: number;
            wait_admin?: number;
        } = {}

        Query parameters, refer to Tasks API for available parameters.

        • Optionalargs?: string

          Argument list (see below; may be wildcarded)

        • Optionalcatalog?: 0 | 1

          A list of all active tasks (queued, running, error, or paused) matching the supplied criteria

        • Optionalcmd?: string

          Task command (e.g., archive.php, modify_xml.php, etc.; may be wildcarded)

        • Optionalcursor?: string

          Cursor for pagination

        • Optionalhistory?: 0 | 1

          A list of all completed tasks matching the supplied criteria

        • Optionalidentifier?: string

          The item identifier, if provided will return tasks for only this item filtered by other criteria provided in params.

        • Optionallimit?: number

          The current default is 50 tasks per request, but the caller may request more with the limit parameter The current maximum limit is 500 tasks. Values outside this range are clamped to the server maximum. If the caller wishes to receive all tasks in a single round-trip, they may set limit=0 in the request query.

          50
          
        • Optionalpriority?: number

          Generally from 10 to -10

        • Optionalserver?: string

          IA node task will or was executed upon (may be wildcarded)

        • Optionalsubmitter?: string

          User submitting task (may be wildcarded)

        • Optionalsubmittime<?: string

          Filter by submit time lower than supplied time. Time must be formatted as "YYYY-MM-DD"

        • Optionalsubmittime<=?: string

          Filter by submit time lower or equal to supplied time. Time must be formatted as "YYYY-MM-DD"

        • Optionalsubmittime>?: string

          Filter by submit time greater than supplied time. Time must be formatted as "YYYY-MM-DD"

        • Optionalsubmittime>=?: string

          Filter by submit time greater or equal to supplied time. Time must be formatted as "YYYY-MM-DD"

        • Optionalsummary?: 0 | 1

          Total counts of catalog tasks meeting all criteria organized by run status (queued, running, error, and paused). Historical totals are currently unavailable.

          1
          
        • Optionaltask_id?: number

          Task identifier

        • Optionalwait_admin?: number

          Task run state (see below)

      Returns Promise<IaCatalogTask[]>

      An array of all queued or running tasks.

    • Beta

      Get a task log.

      Parameters

      • taskId: number

        The task id for the task log you'd like to fetch.

      Returns Promise<string>

      The task log as a string.

    • Beta

      Get a list of all tasks meeting all criteria. The list is ordered by submission time.

      Parameters

      • params: {
            args?: string;
            catalog?: 0 | 1;
            cmd?: string;
            cursor?: string;
            history?: 0 | 1;
            identifier?: string;
            priority?: number;
            server?: string;
            submitter?: string;
            "submittime<"?: string;
            "submittime<="?: string;
            "submittime>"?: string;
            "submittime>="?: string;
            task_id?: number;
            wait_admin?: number;
        }

        params

        • Optionalargs?: string

          Argument list (see below; may be wildcarded)

        • Optionalcatalog?: 0 | 1

          A list of all active tasks (queued, running, error, or paused) matching the supplied criteria

        • Optionalcmd?: string

          Task command (e.g., archive.php, modify_xml.php, etc.; may be wildcarded)

        • Optionalcursor?: string

          Cursor for pagination

        • Optionalhistory?: 0 | 1

          A list of all completed tasks matching the supplied criteria

        • Optionalidentifier?: string

          The item identifier, if provided will return tasks for only this item filtered by other criteria provided in params.

        • Optionalpriority?: number

          Generally from 10 to -10

        • Optionalserver?: string

          IA node task will or was executed upon (may be wildcarded)

        • Optionalsubmitter?: string

          User submitting task (may be wildcarded)

        • Optionalsubmittime<?: string

          Filter by submit time lower than supplied time. Time must be formatted as "YYYY-MM-DD"

        • Optionalsubmittime<=?: string

          Filter by submit time lower or equal to supplied time. Time must be formatted as "YYYY-MM-DD"

        • Optionalsubmittime>?: string

          Filter by submit time greater than supplied time. Time must be formatted as "YYYY-MM-DD"

        • Optionalsubmittime>=?: string

          Filter by submit time greater or equal to supplied time. Time must be formatted as "YYYY-MM-DD"

        • Optionaltask_id?: number

          Task identifier

        • Optionalwait_admin?: number

          Task run state (see below)

      Returns Promise<IaCatalogTask[]>

      A set of all tasks meeting all criteria.

    • Beta

      Returns rate limit for specified task type

      Type Parameters

      • T extends
            | "book_op.php"
            | "bup.php"
            | "delete.php"
            | "derive.php"
            | "fixer.php"
            | "make_dark.php"
            | "make_undark.php"
            | "rename.php"

      Parameters

      • cmd:
            | "book_op.php"
            | "bup.php"
            | "delete.php"
            | "derive.php"
            | "fixer.php"
            | "make_dark.php"
            | "make_undark.php"
            | "rename.php" = 'derive.php'

        Task type

      Returns Promise<
          {
              cmd: T;
              tasks_blocked_by_offline: number;
              tasks_inflight: number;
              tasks_limit: number;
          },
      >

      Rate limit object

      IaApiError

    • Beta

      Get top collections from the collections endpoint of the home page API

      Parameters

      • count: number = 50

        number of top collections to return

      • page: number = 1

        Page number

      Returns Promise<IaTopCollectionInfo[]>

      Array of up to count items of collection info

    • Beta

      Check if the item identifier is available for creating a new item.

      Parameters

      • identifier: string

      Returns Promise<boolean>

      true if identifier is available, or false if it is not available.

    post

    • Beta

      Parameters

      • Optionalidentifier: string
      • OptionalaccessKey: string

      Returns Promise<boolean>

    • Beta

      Send a HTTP request. This method does not perform any error handling currently.

      Parameters

      • request: Request

        Request to send

      Returns Promise<Response>

      Response

    • Beta

      Submit a task

      Parameters

      • identifier: string

        Item identifier.

      • cmd:
            | "book_op.php"
            | "bup.php"
            | "delete.php"
            | "derive.php"
            | "fixer.php"
            | "make_dark.php"
            | "make_undark.php"
            | "rename.php"

        Task command to submit, see supported task commands

      • __namedParameters: Omit<IaSubmitTaskParams, "identifier" | "cmd"> & { reducedPriority?: boolean }

      Returns Promise<Response>