pjwebco-instagram-graph-api
v3.9.4
Published
This repository contains a set of functions to interact with the Instagram Graph API. These functions allow you to retrieve information about Instagram users, media, reels, TV series, and TV videos. The code is organized into separate modules for each Ins
Downloads
4
Readme
Certainly! Here's a sample README.md
file with documentation for all the generated files:
# Instagram API Documentation
This repository contains a set of functions to interact with the Instagram Graph API. These functions allow you to retrieve information about Instagram users, media, reels, TV series, and TV videos. The code is organized into separate modules for each Instagram feature.
### Configuration
The API Configuration module provides an instance of the `APIConfig` class, which includes the following configuration properties:
- `baseURL` (string): The base URL for API requests.
- `accessToken` (string): The user's access token.
You can set the API configuration by calling the `setConfig` method with either a new configuration object or an access token string. If you provide a configuration object, you can specify the `accessToken` and `baseURL` properties.
```javascript
// Set the library configuration with an access token
API.setConfig("your-access-token");
// Set the library configuration with a new base URL and access token
API.setConfig({
accessToken: "your-access-token",
baseURL: "https://new-api-url.com",
});
```
Instagram User Functions (user.ts)
getUserInfo(username: string): Promise<object>
This function retrieves information about a specific Instagram user.
username
(string): The username of the user to retrieve information for.- Returns a Promise that resolves to the user's data.
- Throws an error if the request fails or if "user" permission is required.
searchUsers(query: string): Promise<object>
This function allows you to search for Instagram users by name or username.
query
(string): The search query.- Returns a Promise that resolves to the search results.
- Throws an error if the request fails or if "user" permission is required.
getUserFollowers(userId: string): Promise<object>
This function retrieves a list of users who follow a specific Instagram user.
userId
(string): The ID of the user to retrieve followers for.- Returns a Promise that resolves to the followers data.
- Throws an error if the request fails or if "followers" permission is required.
getUserFollowing(userId: string): Promise<object>
This function retrieves a list of users that a specific Instagram user is following.
userId
(string): The ID of the user to retrieve following for.- Returns a Promise that resolves to the following data.
- Throws an error if the request fails or if "following" permission is required.
Instagram Media Functions (media.ts)
getMediaInfo(mediaId: string): Promise<object>
This function retrieves information about a specific Instagram media object.
mediaId
(string): The ID of the media object to retrieve.- Returns a Promise that resolves to the media object's data.
- Throws an error if the request fails.
searchMediaByHashtag(hashtag: string): Promise<object>
This function allows you to search for Instagram media objects by hashtag.
hashtag
(string): The hashtag to search for.- Returns a Promise that resolves to the search results.
- Throws an error if the request fails.
getCommentInfo(commentId: string): Promise<object>
This function retrieves information about a specific Instagram comment.
commentId
(string): The ID of the comment to retrieve.- Returns a Promise that resolves to the comment data.
- Throws an error if the request fails.
searchCommentsOnMedia(mediaId: string): Promise<object>
This function allows you to search for comments on a specific media object by media ID.
mediaId
(string): The ID of the media object to search for comments on.- Returns a Promise that resolves to the comments data.
- Throws an error if the request fails.
getUserMedia(username: string, options?: number | GetUserMediaOptions): Promise<object>
This function fetches a user's media by username with optional media type and limit.
username
(string): Instagram username.options
(number | GetUserMediaOptions): Optional parameters for media type and limit.- Returns a Promise that resolves to the user's media data.
- Throws an error if the request fails.
getMediaLikes(mediaId: string): Promise<object>
This function retrieves a list of users who have liked a specific Instagram media object.
mediaId
(string): The ID of the media object to retrieve likes for.- Returns a Promise that resolves to the likes data.
- Throws an error if the request fails.
getMediaComments(mediaId: string): Promise<object>
This function retrieves a list of comments on a specific Instagram media object.
mediaId
(string): The ID of the media object to retrieve comments for.- Returns a Promise that resolves to the comments data.
- Throws an error if the request fails.
Instagram Reels Functions (reels.ts)
getReelInfo(reelId: string): Promise<object>
This function retrieves information about a specific Instagram Reel.
reelId
(string): The ID of the Reel to retrieve.- Returns a Promise that resolves to the Reel data.
- Throws an error if the request fails.
searchReels(query: string): Promise<object>
This function allows you to search for Instagram Reels.
query
(string): The search query.- Returns a Promise that resolves to the search results.
- Throws an error if the request fails.
getMentions(username: string): Promise<object>
This function retrieves a list of comments that mention a specific Instagram user.
username
(string): The Instagram username to search for mentions.- Returns a Promise that resolves to the mention data.
- Throws an error if the request fails.
Instagram TV Functions (tv.ts)
getTvSeriesInfo(seriesId: string): Promise<object>
This function retrieves information about a specific Instagram TV series.
seriesId
(string): The ID of the TV series to retrieve.- Returns a Promise that resolves to the TV series data.
- Throws an error if the request fails.
searchTvSeries(query: string): Promise<object>
This function allows you to search for Instagram TV series.
query
(string): The search query.- Returns a Promise that resolves to the search results.
- Throws an error if the request fails.
getTvVideoInfo(videoId: string): Promise<object>
This function retrieves information about a specific Instagram TV video.
videoId
(string): The ID of the TV video to retrieve.- Returns a Promise that resolves to the TV video data.
- Throws an error if the request fails.
searchTvVideos(query: string): Promise<object>
This function allows you to search for Instagram TV videos.
query
(string): The search query.- Returns a Promise that resolves to the search results.
- Throws an error if the request fails.
License
This code is provided under the MIT license.
You can use this `README.md` as a starting point and modify it as needed to suit your project's specific requirements.