@sno2/pex
Version:
An unofficial promise-based Pexels API wrapper with top-notch TypeScript support.
58 lines (57 loc) • 2.39 kB
TypeScript
import type { Photo, PhotoQuery, PhotosQuery, Video, VideoQuery, VideosQuery, PopularVideosQuery, PaginatedData, PaginatedOpts } from "./types";
export interface PexOpts {
key: string;
}
/**
* The main class used to utilize the Pexels API.
*
* ## Example
*
* ```ts
* const pex = new Pex({ key: "YOUR_API_KEY" });
* const photo = await pex.getPhoto({ id: "" });
* ```
*/
export declare class Pex {
#private;
/**
* @param opts The options that includes your Pexels API key.
*/
constructor(opts: PexOpts);
/**
* Gets a single photo object.
* @param queryOpts An object that includes the `id` of the specified photo and some other options.
* @returns The queried photo.
*/
getPhoto(queryOpts: PhotoQuery): Promise<Photo>;
/**
* Gets multiple photos based upon the search `query` specified in the `queryOpts` parameter and the other properties in `queryOpts`.
* @param queryOpts The options used to search/filter/sort through the photos.
* @returns The paginated photos response.
*/
getPhotos(queryOpts: PhotosQuery & PaginatedOpts): Promise<PaginatedData<["photos", Photo]>>;
/**
* Gets the curated photos from the Pexels API.
* @param paginatedOpts The options to specify the behavior of the paginated response (limit per page, ect.).
* @returns The paginated, curated photos.
*/
getCuratedPhotos(paginatedOpts: PaginatedOpts): Promise<PaginatedData<["photos", Photo]>>;
/**
* Gets a given video based upon the `id` in the `queryOpts` parameter.
* @param queryOpts The options used to get the video data.
* @returns The video object.
*/
getVideo(queryOpts: VideoQuery): Promise<Video>;
/**
* Gets multiple videos based upon the query options.
* @param queryOpts The options used to query for videos.
* @returns The paginated videos the match your query options.
*/
getVideos(queryOpts: VideosQuery & PaginatedOpts): Promise<PaginatedData<["videos", Photo]>>;
/**
* Gets the popular videos based upon the query options.
* @param queryOpts The options used to query for videos.
* @returns The paginated popular videos.
*/
getPopularVideos(queryOpts: PopularVideosQuery & PaginatedOpts): Promise<PaginatedData<["videos", Photo]>>;
}