internetarchive-sdk-js
Version:
NodeJS / Typescript SDK for Internet Archive APIs
104 lines (103 loc) • 4.77 kB
TypeScript
import HttpClient from './HttpClient.js';
import { type IaOptions, Mediatype, FileUpload, CreateItemResponse, UpdateItemParams, UpdateItemResponse, GetItemResponse, GetItemTasksResponse, TaskCriteria, GetItemsResponse, GetItemsParams } from './types.js';
export * from './types.js';
declare class InternetArchive {
token?: string | null;
options?: IaOptions;
httpClient: HttpClient;
static default: typeof InternetArchive;
/**
* Provides access to Internet Archive APIs through methods
*
* @param token - {@link https://archive.org/developers/tutorial-get-ia-credentials.html S3-like API Key} formatted as "accesskey:secretkey" (required for all methods except getItem or getItems)
* @param options - InternetArchive API options
* @param options.testmode - Option to add item to {@link https://archive.org/details/test_collection Test Collection} (auto deletes in 30 days) - default FALSE
* @param options.setScanner - option to add scanner metadata for internetarchive-sdk-js - default TRUE
* @see {@link https://archive.org/developers/tutorial-get-ia-credentials.html Archive.org - Get your Internet Archive credentials}
* @see {@link https://archive.org/details/test_collection Archive.org - Test Collection}
*/
constructor(token?: string, options?: IaOptions);
/**
* Creates an Item in a Collection (Uploads a file and adds metadata).
*
* @param item - identifier, collection, mediatype, upload, metadata.
* @param item.identifier - The unique identifier for the item.
* @param item.collection - The collection that the item belongs to.
* @param item.mediatype - The item mediatype.
* @param item.upload - The item upload.
* @param item.metadata - The item metadata (optional).
* @returns The item identifier, metadata, and upload filename.
*
* @see {@link https://archive.org/developers/ias3.html Archive.org - ias3 Internet archive S3-like API}
*/
createItem(item: {
identifier: string;
collection: string;
mediatype: Mediatype;
upload: FileUpload;
metadata?: Record<string, unknown>;
}): Promise<CreateItemResponse>;
/**
* Returns Items based on filters and options.
*
* @param items - filters (collection, subject, creator) and options (fields, rows).
* @param items.filters - Filter by collection, subject, creator.
* @param items.options - Options to specify fields returned and amount of items.
* @returns The responseHeader and response with items as docs.
*
* @see {@link https://archive.org/advancedsearch.php Archive.org - Advanced Search API}
*/
getItems(items: GetItemsParams): Promise<GetItemsResponse>;
/**
* Returns an Item by identifier.
*
* @param identifier - The unique identifier for the item.
* @returns Item metadata, file paths, and other info.
*
* @see {@link https://archive.org/developers/metadata.html Archive.org - Item Metadata API API}
*/
getItem(identifier: string): Promise<GetItemResponse>;
/**
* Updates an Item by identifier and metadata.
*
* @param identifier - The unique identifier for the item.
* @param metadata - The item metadata.
* @returns Update response (success, error, task_id, log).
*
* @see {@link https://archive.org/developers/metadata.html Archive.org - Item Metadata API API}
*/
updateItem(identifier: string, metadata: UpdateItemParams): Promise<UpdateItemResponse>;
/**
* Uploads a File to a parent Item.
*
* @param upload - identifier, mediatype, file.
* @param upload.identifier - The unique identifier of the parent item.
* @param upload.mediatype - The upload mediatype.
* @param upload.file - The upload file.
*
* @see {@link https://archive.org/developers/ias3.html Archive.org - ias3 Internet archive S3-like API}
*/
uploadFile(upload: {
identifier: string;
mediatype: Mediatype;
file: FileUpload;
}): Promise<void>;
/**
* Deletes a File from an Item.
*
* @param path - The path of the file [identifier/filename].
*
* @see {@link https://archive.org/developers/ias3.html Archive.org - ias3 Internet archive S3-like API}
*/
deleteFile(path: string): Promise<void>;
/**
* Returns Tasks from an Item.
*
* @param identifier - identifier, mediatype, file.
* @param criteria - Parameters to filter item tasks.
*
* @see {@link https://archive.org/developers/tasks.html Archive.org - Tasks API}
*/
getItemTasks(identifier: string, criteria?: TaskCriteria): Promise<GetItemTasksResponse>;
}
export default InternetArchive;