0.0.2 • Published 1 year ago

ao3api v0.0.2

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

README

Disclaimer: This is not officially supported. This is functionality I desired for a personal program and thought I'd publish.

This package requires login details, as it's meant to access private things like history. Be careful how you use this.

Main relevant methods:

    export interface Work {
        title: string;
        language: string;
        chapters: number;
        comments: number;
        kudos: number;
        bookmarks: number;
        hits: number;
        url?: string;
        updated: boolean;
        fandoms: string[];
        authors: string[];
        /** Keys can be: category, rating, warning, fandom,
         * relationship, character, freeform
         */
        tags: Record<string, string[]>;
    }
    /** 
     * Instantiate an Ao3Session with username and password for use of the * package.
     */
    export declare class Ao3Session {
        constructor(name: string, pass: string);
        getCsrfToken(): Promise<string | undefined>;
        getHistory(page?: number): Promise<Work[]>;
        getBookmarks(page?: number): Promise<Work[]>;
        getWork(num: string | number): Promise<Work | null>;
    }

Example:

    import {Ao3Session} from 'ao3api';
    const s = new Ao3Session('SomeUser', 'SomePass');
    // get the last 20 works SomeUser read - every page is 20 works.
    await s.getHistory(1);
    // get a page of the user's bookmarks - each page is 20 works.
    await s.getBookmarks(1);
    // get a breakdown of a work
    await s.getWork(24940906) // returns a Work