This module provides a simple API to
- Get insights for you instagram account
- Get metrics for your instagram posts
- Get posts from other instagram accounts
- Get(urlPath, params) ⇒
Promise.<Object, Error> Get request to Facebook API
- Discover(urlPath, fields, token, posts) ⇒
Promise.<Array.<DiscoveryPosts>, Error> Business discovery request for Facebook API
- GetAll(urlPath, params) ⇒
Promise.<Array.<Object>, Error> Get request to Facebook API reading paginated results. Results will be read until no more 'next' cursor is returned in response
- GetPost(urlPath, token) ⇒
Promise.<Post, Error> Returns post caption,media_type,media_url,children,media_url,comment_count,like_count, and impressions from an Instagram post. Ex. '/v11.0/12437548796' would request post content for post with Id 12437548796
- GetInsights(urlPath, token, daysAgo) ⇒
Promise.<(Metrics|Error)> Returns reach,impressions,and follower_count metrics of an instagram profile aggregated over a time range from n days ago up to current date
- GetAudiences(urlPath, token) ⇒
Promise.<Array, Error> Returns countries and cities for Instagram user followers
- DiscoverUserPosts(urlPath, userName, daysAgo, token) ⇒
Promise.<Array.<DiscoveryPosts>, Error> Returns posts for Instagram user using business dicovery since 'daysAgo' till current date
- GetFbPosts(urlPath, daysAgo, token) ⇒
Promise.<Array.<Post>, Error> Returns Facebook user posts
- GetFbPostMetrics(urlPath, token) ⇒
Promise.<PostMetric, Error> Returns Facebook user post metrics
Get request to Facebook API
Kind: global function
Returns: Promise.<Object, Error> - Promise to the request response
| Param | Type | Description |
|---|---|---|
| urlPath | string |
URL path for request. Must start with api version ex: /v11.0/.. |
| params | Object |
Query parameters as key value pairs. Check the documentation https://developers.facebook.com/docs/instagram for valid key value pairs |
| params.fields | string |
Comma separated list of fields and edges to be returned |
| params.access_token | string |
Facebook API access token |
Example:
fb.Get('/v11.0/your_ig_user_id',{
'fields':'name',
'access_token':'your_access_token'
}).then((data)=>{
//Do something with data
}).catch((err)=>{
//Do something with error
})Business discovery request for Facebook API
Kind: global function
Returns: Promise.<Array.<DiscoveryPosts>, Error> - Promise to the request response
| Param | Type | Description |
|---|---|---|
| urlPath | string |
URL path for request. Must start with api version ex: /v11.0/.. |
| fields | Object |
Object with the following properties: userName,startDate,endDate |
| fields.userName | string |
The userName of the instagram account to query (required) |
| fields.startDate | string |
Start date of request in ISO Layout 'YYYY-MM-DD' |
| fields.endDate | string |
End date of request in ISO Layout 'YYYY-MM-DD' |
| token | string |
Facebook API access token |
| posts | Array |
Array to append results to |
Example:
fb.Discover('/v11.0/your_ig_user_id',{
userName: 'esmuellert', //Here esmuellert is the instagram user name we want to discover
startDate: '2021-06-29',
endDate:'2021-06-30',
},'your_access_token',[]).then((data)=>{
//Do something with data
}).catch((err)=>{
//Do something with error
})Get request to Facebook API reading paginated results. Results will be read until no more 'next' cursor is returned in response
Kind: global function
Returns: Promise.<Array.<Object>, Error> - Promise to the request response
| Param | Type | Description |
|---|---|---|
| urlPath | string |
URL path for request. Must start with api version ex: /v11.0/.. |
| params | string |
Query parameters as key value pairs. Check the documentation https://developers.facebook.com/docs/instagram for valid key value pairs |
Example
fb.GetAll('/v11.0/your_ig_user_id/media',{
'fields':'timestamp,caption,media_type,children{media_url}',
'access_token':'your_access_token',
}).then((data)=>{
//Do something with data
}).catch((err)=>{
//Do something with error
})Returns post caption,media_type,media_url,children,media_url,comment_count,like_count, and impressions from an Instagram post. Ex. '/v11.0/12437548796' would request post content for post with Id 12437548796
Kind: global function
Returns: Promise.<Post, Error> - Promise object represents request payload
| Param | Type | Description |
|---|---|---|
| urlPath | string |
URL path for request. Must start with api version and end with post ID ex: '/v11.0/12341234' where 12341234 is the post ID you want to query |
| token | string |
Facebook API access token |
Exampe
fb.GetPost('/v11.0/your_post_id','your_access_token').then((data)=>{
//Do something with data
}).catch((err)=>{
//Do something with error
})Returns reach,impressions,and follower_count metrics of an instagram profile aggregated over a time range from n days ago up to current date
Kind: global function
Returns: Promise.<(Metrics|Error)> - Promise object represents request payload
| Param | Type | Description |
|---|---|---|
| urlPath | string |
URL path for request. Must start with api version, then indicate Instagram user ID you want to query, and end with 'insights' path. Ex: '/v11.0/123412345/insights' where 123412345 is the Instagram user Id |
| token | string |
access token for Facebook API |
| daysAgo | Number |
Number of days you want to query. Ex 2 means you want to query insights from 2 days ago till today |
Example
fb.GetInsights('/v11.0/your_ig_user/insights','your_access_token',11).then((data)=>{
//Do something with data
}).catch((err)=>{
//Do something with error
})Returns countries and cities for Instagram user followers
Kind: global function
Returns: Promise.<(Audiences|Error)> - Promise object represents request payload
| Param | Type | Description |
|---|---|---|
| urlPath | string |
URL path for request. Must start with api version. then indicate Instagram user ID you want to query, and end with 'insights' path. Ex: '/v11.0/123412345/insights' where 123412345 is the Instagram user Id |
| token | string |
access token for Facebook API |
Example
fb.GetAudiences('/v11.0/your_instagram_id/insights','your_access_token').then((data)=>{
//Do something with data
}).catch((err)=>{
//Do something with error
})Returns posts for Instagram user using business dicovery since 'daysAgo' till current date
Kind: global function
Returns: Promise.<Array.<DiscoveryPosts>, Error> - Promise to the request response
| Param | Type | Description |
|---|---|---|
| urlPath | string |
URL path for request. Must start with api version ex: /v11.0/.. |
| userName | string |
The userName of the instagram account to query (required) |
| daysAgo | number |
Number of days you want to query. Ex 2 means you want to query posts from 2 days ago till today |
| token | string |
Facebook API access token |
Example
fb.DiscoverUserPosts('/v11.0/your_ig_user_id','instagram_user_to_discover',18,'your_acces_token').then((data)=>{
//Do something with data
}).catch((err)=>{
//Do something with error
})Returns Facebook user posts
Kind: global function
Returns: Promise.<Array.<FbPost>, Error> - Promise to the request response
| Param | Type | Description |
|---|---|---|
| urlPath | string |
URL path for request. Must start with api version ex: /v11.0/.. |
| daysAgo | Number |
Number of days you want to query. Ex 2 means you want to query posts from 2 days ago till today |
| token | string |
Facebook API access token |
Example
fb.GetFbPosts('/v11.0/your_user_id/posts',3,'your_access_token').then((data)=>{
//Do something with data
}).catch((err)=>{
//Do something with error
})Returns Facebook user post metrics
Kind: global function
Returns: Promise.<PostMetric, Error> - Promise to the request response
| Param | Type | Description |
|---|---|---|
| urlPath | string |
URL path for request. Must start with api version ex: /v11.0/.. |
| token | string |
Facebook API access token |
Example
fb.GetFbPostMetrics('/v11.0/your_post_id','your_access_token').then((data)=>{
//Do something with data
}).catch((err)=>{
//Do something with error
})Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| data | Array.<DiscoveryPosts> |
Array with posts children |
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| timestamp | string |
Date when posts was posted |
| caption | string |
Post caption |
| media_type | string |
Post type (CAROUSEL_ALBUM, IMAGE, or VIDEO) |
| media_url | string |
video or image URL |
| children | PostChildren |
Post's children |
| id | string |
Post ID |
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| data | Array.<Post> |
Array with Post's children |
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| id | string |
Post ID |
| timestamp | string |
Date |
| caption | string |
Post caption |
| media_type | string |
Post type (CAROUSEL_ALBUM, IMAGE, or VIDEO) |
| media_url | string |
video or image URL |
| comments_count | number |
Comment counts on the post |
| like_count | number |
Like counts on the post |
| impressions | number |
Number of times post has been seen |
| engagement | number |
Sum of likes_count, comment_count and saved counts on post |
| insights | Object |
Social interaction metrics on the post |
| children | Children |
Post's children |
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| reach | number |
Number of unique users ho have viewed at least one post from the Instagram user |
| impressions | number |
Number of times posts from the Instagram user have been seen |
| follower_count | number |
Sum of new followers within the specified range |
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| countries | object |
Object whose properties are the country codes from Instagram followers, with property values as the number of followers fromeach country. |
| citues | object |
Object whose propertiesare the city names, with property values as the number of followers from each city |
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| id | string |
Post ID |
| message | string |
Post message |
| type | string |
Post type, ex: video, photo |
| picture_uri | string |
Post image uri if it contains a picture |
| video_uri | string |
Post video uri if it contains a video |
| created_time | string |
The time the post was published |
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| comments | number |
Number of people who commented post |
| reactions | number |
Number of people who reacted to post |