@re621/zestyapi
Version:
Comprehensive JS wrapper for e621.net API
71 lines (70 loc) • 2.72 kB
TypeScript
import Endpoint, { QueryParams } from "../components/Endpoint";
import { FormattedResponse } from "../components/RequestQueue";
import { SimpleMap } from "../components/UtilType";
import APIPost from "../responses/APIPost";
export default class PostsEndpoint extends Endpoint<APIPost> {
/**
* Search for posts with specified tags.
* Note that the hard limit for this request is 40 tags.
* Page number and post limit can be specified as parameters.
* @param {PostSearchParams} params Search parameters
* @returns {FormattedResponse<APIPost[]>} Post data
*/
find(query?: PostQueryParams): Promise<FormattedResponse<APIPost>>;
/**
* Fetch post data for a specific post
* @param {number} id ID of the post to return
* @returns {FormattedResponse<APIPost>} Post data
*/
get(id: number): Promise<FormattedResponse<APIPost>>;
/**
* Fetches data for multiple posts by their IDs.
* Note that up to 100 IDs are accepted at a time. Everything past that will be discarded.
* @param ids List of post IDs
* @returns {FormattedResponse<APIPost[]>} Post data
*/
getMany(ids: number[]): Promise<FormattedResponse<APIPost>>;
/**
* Fetches data for a random post
* @returns {FormattedResponse<APIPost>}Post data
*/
random(): Promise<FormattedResponse<APIPost>>;
/**
* Search for posts with specified tags.
* Note that the hard limit for this request is 39 tags.
* Page number and post limit can be specified as parameters.
* @param {PostQueryParams} query Search parameters
* @param {string} seed Random seed. Optional.
* @returns {FormattedResponse<APIPost[]>} Post data
*/
randomMany(query?: PostQueryParams, seed?: string): Promise<FormattedResponse<APIPost>>;
update(id: number, data: PostUpdateParams): Promise<FormattedResponse<APIPost>>;
protected validateQueryParams(params?: PostQueryParams): PostQueryParams;
}
interface PostQueryParams extends QueryParams {
tags?: string | string[];
}
interface PostUpdateParams extends SimpleMap {
tag_string?: string;
old_tag_string?: string;
tag_string_diff?: string;
rating?: "e" | "q" | "s";
old_rating?: "e" | "q" | "s";
parent_id?: number;
old_parent_id?: number;
source?: string;
old_source?: string;
source_diff?: string;
description?: string;
old_description?: string;
edit_reason?: string;
is_rating_locked?: boolean;
is_note_locked?: boolean;
bg_color?: string;
is_status_locked?: boolean;
is_comment_disabled?: boolean;
locked_tags?: string;
hide_from_anonymous?: boolean;
hide_from_search_engines?: boolean;
}
export {};