UNPKG

instagram-graph-api

Version:

A library to help perform requests to the Instagram Graph API.

349 lines (348 loc) 15.4 kB
import { ApiVersion, CommentField, ContainerField, ContentPublishingLimitFields, DayMetric, HashtagMediaField, LifetimeMetric, MediaField, PageField, PublicMediaField, SimplePostMetric, StoryMetric, WeekAndMonthMetric } from './Enums'; import { DeleteCommentRequest } from './requests/comment/DeleteCommentRequest'; import { GetCommentRequest } from './requests/comment/GetCommentRequest'; import { PostHideCommentRequest } from './requests/comment/PostHideCommentRequest'; import { GetRepliesRequest } from './requests/comment/replies/GetRepliesRequest'; import { PostReplyRequest } from './requests/comment/replies/PostReplyRequest'; import { GetContainerRequest } from './requests/container/GetContainerRequest'; import { GetHashtagRecentMediaRequest } from './requests/hashtag/media/GetHashtagRecentMediaRequest'; import { GetHashtagTopMediaRequest } from './requests/hashtag/media/GetHashtagTopMediaRequest'; import { GetHashtagIdRequest } from './requests/hashtag/search/GetHashtagIdRequest'; import { GetMediaChildrenRequest } from './requests/media/children/GetMediaChildrenRequest'; import { GetMediaCommentsRequest } from './requests/media/comments/GetMediaCommentsRequest'; import { PostMediaCommentRequest } from './requests/media/comments/PostMediaCommentRequest'; import { GetMediaInfoRequest } from './requests/media/info/GetMediaInfoRequest'; import { GetSimplePostMediaInsightsRequest } from './requests/media/insights/GetSimplePostMediaInsightsRequest'; import { GetStoryMediaInsightsRequest } from './requests/media/insights/GetStoryMediaInsightsRequest'; import { GetContentPublishingLimitRequest } from './requests/page/content_publishing_limit/GetContentPublishingLimitRequest'; import { GetPageInfoRequest } from './requests/page/info/GetPageInfoRequest'; import { GetPageDayInsightsRequest } from './requests/page/insights/GetPageDayInsightsRequest'; import { GetPageLifetimeInsightsRequest } from './requests/page/insights/GetPageLifetimeInsightsRequest'; import { GetPageMonthInsightsRequest } from './requests/page/insights/GetPageMonthInsightsRequest'; import { GetPageWeekInsightsRequest } from './requests/page/insights/GetPageWeekInsightsRequest'; import { GetInstagramAccountInfoRequest } from './requests/page/instagram_account_info/GetInstagramAccountInfoRequest'; import { GetPageMediaRequest } from './requests/page/media/GetPageMediaRequest'; import { PostPageCarouselMediaRequest } from './requests/page/media/PostPageCarouselMediaRequest'; import { PostPagePhotoMediaRequest } from './requests/page/media/PostPagePhotoMediaRequest'; import { PostPublishMediaRequest } from './requests/page/media_publish/PostPublishMediaRequest'; import { GetPageRecentlySearchedHashtagsRequest } from './requests/page/recently_searched_hashtags/GetPageRecentlySearchedHashtagsRequest'; import { GetPageStoriesRequest } from './requests/page/stories/GetPageStoriesRequest'; import { GetTagsRequest } from './requests/page/tags/GetTagsRequest'; import { UserTag } from './requests/Params'; import { PostPageReelMediaRequest } from './requests/page/media/PostPageReelMediaRequest'; import { PostPageStoriesPhotoMediaRequest } from './requests/page/media/PostPageStoriesPhotoMediaRequest'; import { PostPageStoriesVideoMediaRequest } from './requests/page/media/PostPageStoriesVideoMediaRequest'; /** * A client that creating requests. * * @author Tiago Grosso <tiagogrosso99@gmail.com> * @since 0.2.0 */ export declare class Client { /** * The API access token. */ private readonly accessToken; /** * The id of the page. This is used on page related requests, so it should be the page for which the access token has permissions. */ private readonly pageId; /** * The API version to use on requests. */ private readonly apiVersion?; /** * The constructor. * * @param accessToken the access token. * @param pageId The id of the page. * @param apiVersion the API version */ constructor(accessToken: string, pageId: string, apiVersion?: ApiVersion); /** * Gets the access token. * * @returns the access token. */ getAccessToken(): string; /** * Gets the page id. * * @returns the page id. */ getPageId(): string; /** * Builds a new {@link GetPageInfoRequest}. * * @param fields the fields to retrieve from the API. If no field is specified, all are retrieved. * * @returns a new {@link GetPageInfoRequest}. */ newGetPageInfoRequest(...fields: PageField[]): GetPageInfoRequest; /** * Builds a new {@link GetPageMediaRequest}. * * @param fields the fields to retrieve from the API for each media object. If no field is specified, all are retrieved. * * @returns a new {@link GetPageMediaRequest}. */ newGetPageMediaRequest(...fields: MediaField[]): GetPageMediaRequest; /** * Builds a new {@link GetPageLifetimeInsightsRequest}. * * @param metrics the metrics to retrieve from the API. If no metric is specified, all are retrieved. * * @returns a new {@link GetPageLifetimeInsightsRequest}. */ newGetPageLifetimeInsightsRequest(...metrics: LifetimeMetric[]): GetPageLifetimeInsightsRequest; /** * Builds a new {@link GetPageDayInsightsRequest}. * * @param metrics the metrics to retrieve from the API. If no metric is specified, all are retrieved. * * @returns a new {@link GetPageDayInsightsRequest}. */ newGetPageDayInsightsRequest(...metrics: DayMetric[]): GetPageDayInsightsRequest; /** * Builds a new {@link GetPageWeekInsightsRequest}. * * @param metrics the metrics to retrieve from the API. If no metric is specified, all are retrieved. * * @returns a new {@link GetPageWeekInsightsRequest}. */ newGetPageWeekInsightsRequest(...metrics: WeekAndMonthMetric[]): GetPageWeekInsightsRequest; /** * Builds a new {@link GetPageMonthInsightsRequest}. * * @param metrics the metrics to retrieve from the API. If no metric is specified, all are retrieved. * * @returns a new {@link GetPageMonthInsightsRequest}. */ newGetPageMonthInsightsRequest(...metrics: WeekAndMonthMetric[]): GetPageMonthInsightsRequest; /** * Builds a new {@link GetMediaInfoRequest}. * * @param mediaId the media object id. * @param fields the fields to retrieve from the API. If no field is specified, all are retrieved. * * @returns a new {@link GetMediaInfoRequest}. */ newGetMediaInfoRequest(mediaId: string, ...fields: MediaField[]): GetMediaInfoRequest; /** * Builds a new {@link GetMediaChildrenRequest}. * * @param mediaId the media object id. * * @returns a new {@link GetMediaChildrenRequest}. */ newGetMediaChildrenRequest(mediaId: string): GetMediaChildrenRequest; /** * Builds a new {@link GetMediaCommentsRequest}. * * @param mediaId the media object id. * @param fields the fields to retrieve from the API. If no field is specified, all are retrieved. * * @returns a new {@link GetMediaCommentsRequest}. */ newGetMediaCommentsRequest(mediaId: string, ...fields: CommentField[]): GetMediaCommentsRequest; /** * Builds a new {@link PostMediaCommentRequest}. * * @param mediaId the media object id. * @param text the text of the comment, * * @returns a new {@link PostMediaCommentRequest}. */ newPostMediaCommentRequest(mediaId: string, text: string): PostMediaCommentRequest; /** * Builds a new {@link GetSimplePostMediaInsightsRequest}. * * @param mediaId the media object id (must be of type 'Photo' or 'Video'). * @param metrics the metrics to retrieve from the API. If no metric is specified, all are retrieved. * * @returns a new {@link GetSimplePostMediaInsightsRequest}. */ newGetSimplePostMediaInsightsRequest(mediaId: string, ...metrics: SimplePostMetric[]): GetSimplePostMediaInsightsRequest; /** * Builds a new {@link GetStoryMediaInsightsRequest}. * * @param mediaId the media object id (must be of type 'Story'). * @param metrics the metrics to retrieve from the API. If no metric is specified, all are retrieved. * * @returns a new {@link GetStoryMediaInsightsRequest}. */ newGetStoryMediaInsightsRequest(mediaId: string, ...metrics: StoryMetric[]): GetStoryMediaInsightsRequest; /** * Builds a new {@link GetHashtagIdRequest}. * * @param hashtag the hashtag. * @param userId (optional) the id of the user making the request. If omitted, the page id is used. * * @returns a new {@link GetHashtagIdRequest}. */ newGetHashtagIdRequest(hashtag: string, userId?: string): GetHashtagIdRequest; /** * Builds a new {@link GetHashtagRecentMediaRequest}. * * @param hashtagId the hashtag id. * @param userId (optional) the id of the user making the request. If omitted, the page id is used. * @param fields the media fields to retrieve from the API. If no field is specified, all are retrieved. * * @returns a new {@link GetHashtagRecentMediaRequest}. */ newGetHashtagRecentMediaRequest(hashtagId: string, userId?: string, ...fields: HashtagMediaField[]): GetHashtagRecentMediaRequest; /** * Builds a new {@link GetHashtagTopMediaRequest}. * * @param hashtagId the hashtag id. * @param userId (optional) the id of the user making the request. If omitted, the page id is used. * @param fields the media fields to retrieve from the API. If no field is specified, all are retrieved. * * @returns a new {@link GetHashtagTopMediaRequest}. */ newGetHashtagTopMediaRequest(hashtagId: string, userId?: string, ...fields: HashtagMediaField[]): GetHashtagTopMediaRequest; /** * Builds a new {@link GetCommentRequest}. * * @param commentId the comment id. * @param fields the comment fields to retrieve from the API. If no field is specified, all are retrieved. * * @returns a new {@link GetCommentRequest}. */ newGetCommentRequest(commentId: string, ...fields: CommentField[]): GetCommentRequest; /** * Builds a new {@link PostHideCommentRequest}. * * @param commentId the comment id. * @param hide whether to hide or show the comment (default: true). * * @returns a new {@link PostHideCommentRequest}. */ newPostHideCommentRequest(commentId: string, hide?: boolean): PostHideCommentRequest; /** * Builds a new {@link DeleteCommentRequest}. * * @param commentId the comment id. * * @returns a new {@link DeleteCommentRequest}. */ newDeleteCommentRequest(commentId: string): DeleteCommentRequest; /** * Builds a new {@link GetRepliesRequest}. * * @param commentId the comment id. * @param fields the comment fields to retrieve from the API. If no field is specified, all are retrieved. * * @returns a new {@link GetRepliesRequest}. */ newGetRepliesRequest(commentId: string, ...fields: CommentField[]): GetRepliesRequest; /** * Builds a new {@link PostReplyRequest}. * * @param commentId the comment id. * @param text the text of the reply. * * @returns a new {@link PostReplyRequest}. */ newPostReplyRequest(commentId: string, text: string): PostReplyRequest; /** * Builds a new {@link GetTagsRequest}. * * @param fields the fields to retrieve from the API for each media object. If no field is specified, all are retrieved. * * @returns a new {@link GetTagsRequest}. */ newGetTagsRequest(...fields: PublicMediaField[]): GetTagsRequest; /** * Builds a new {@link GetContainerRequest}. * * @param containerId the container id. * @param fields the fields to retrieve from the API. * * @returns a new {@link GetCommentRequest}. */ newGetContainerRequest(containerId: string, ...fields: ContainerField[]): GetContainerRequest; /** * Build a new {@link PostPagePhotoMediaRequest}. * * @param imageUrl the image URL. * @param caption the caption. * @param locationId the location id. * @param userTags the user_tags. * * @returns a new {@link PostPagePhotoMediaRequest}. */ newPostPagePhotoMediaRequest(imageUrl: string, caption?: string, locationId?: string, userTags?: UserTag[]): PostPagePhotoMediaRequest; /** * Build a new {@link PostPageReelMediaRequest}. * * @param videoUrl the video URL. * @param caption the caption. * @param thumbOffset the thumbnail offset. * @param shareToFeed whether the reel should be shared in the feed as well. * @param locationId the location id. * * @returns a new {@link PostPageReelMediaRequest}. */ newPostPageReelMediaRequest(videoUrl: string, caption?: string, thumbOffset?: number, shareToFeed?: boolean, locationId?: string): PostPageReelMediaRequest; /** * Build a new {@link PostPageCarouselMediaRequest}. * * @param caption the caption. * @param locationId the location id. * @param children the carousel children. * * @returns a new {@link PostPageCarouselMediaRequest}. */ newPostPageCarouselMediaRequest(children?: string[], caption?: string, locationId?: string): PostPageCarouselMediaRequest; /** * Build a new {@link PostPageStoriesPhotoMediaRequest}. * * @param imageUrl the image URL. * * @returns a new {@link PostPageStoriesPhotoMediaRequest}. */ newPostPageStoriesPhotoMediaRequest(imageUrl: string): PostPageStoriesPhotoMediaRequest; /** * Build a new {@link PostPageStoriesVideoMediaRequest}. * * @param videoUrl the video URL. * * @returns a new {@link PostPageStoriesVideoMediaRequest}. */ newPostPageStoriesVideoMediaRequest(videoUrl: string): PostPageStoriesVideoMediaRequest; /** * Builds a new {@link PostPublishMediaRequest}. * * @param containerId the container id. * * @returns a new {@link PostPublishMediaRequest}. */ newPostPublishMediaRequest(containerId: string): PostPublishMediaRequest; /** * Builds a new {@link GetPageStoriesRequest}. * * @returns a new {@link GetPageStoriesRequest}. */ newGetPageStoriesRequest(): GetPageStoriesRequest; /** * Builds a new {@link GetPageRecentlySearchedHashtagsRequest}. * * @returns a new {@link GetPageRecentlySearchedHashtagsRequest}. */ newGetPageRecentlySearchedHashtagsRequest(): GetPageRecentlySearchedHashtagsRequest; /** * Builds a new {@link GetContentPublishingLimitRequest}. * * @param fields the fields to retrieve. * * @returns a new {@link GetContentPublishingLimitRequest}. */ newGetContentPublishingLimitRequest(...fields: ContentPublishingLimitFields[]): GetContentPublishingLimitRequest; /** * Builds a new {@link GetInstagramAccountInfoRequest}. * * @returns a new {@link GetInstagramAccountInfoRequest}. */ newGetInstagramAccountInfoRequest(): GetInstagramAccountInfoRequest; }