UNPKG

openalex-client

Version:

TypeScript SDK for OpenAlex academic database API

46 lines 1.5 kB
import { OpenAlexClient } from "../client"; import { QueryParams, OpenAlexResponse, AutocompleteResponse, OpenAlexEntity } from "../types"; export declare abstract class BaseService<T extends OpenAlexEntity> { protected client: OpenAlexClient; protected abstract readonly endpoint: string; constructor(client: OpenAlexClient); /** * Get a single entity by ID */ get(id: string, params?: Pick<QueryParams, "select" | "mailto">): Promise<T>; /** * Get multiple entities */ list(params?: QueryParams): Promise<OpenAlexResponse<T>>; /** * Search entities with autocomplete */ autocomplete(query: string, params?: { filter?: string; }): Promise<AutocompleteResponse>; /** * Get random entities */ random(params?: Pick<QueryParams, "filter" | "select" | "mailto">): Promise<OpenAlexResponse<T>>; /** * Get entities with pagination support */ paginate(params?: QueryParams): AsyncGenerator<T, void, unknown>; /** * Get all entities (use with caution for large datasets) */ getAll(params?: QueryParams): Promise<T[]>; /** * Build filter string from object */ protected buildFilter(filters: Record<string, any>): string; /** * Clean and validate ID */ protected cleanId(id: string): string; /** * Build search parameters */ protected buildParams(params?: QueryParams): Record<string, any>; } //# sourceMappingURL=base.d.ts.map