
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@denimlabs/facebook-graph-utils
Advanced tools
A collection of composable utilities to make it easier to consume data from facebook graph and APIs
A collection of composable utilities to make it easier to consume data from facebook graph and APIs
yarn add facebook-graph-utils
None
import FBGraphUtilsFactory from 'facebook-graph-utils'
const FBGraphUtils = FBGraphUtilsFactory('TOKEN', 'APPSECRET')
FBGraphUtils.getAllFbApiData('https://graph.facebook.com/v2.10/act_ACCOUNT_ID/insights')
.then(console.log)
console.log(FBGraphUtils.objectToGetParamsShallow({a:1,b:2}))
//a=1&b=2
const appSecretProof = FBGraphUtils.generateAppsecretProof('token', 'appsecret')
import FBGraphUtilsFactory from 'facebook-graph-utils'
const FBGraphUtils = FBGraphUtilsFactory('TOKEN', 'APPSECRET')
FBGraphUtils
.setLevel('campaign')
.setInsightsFields()
.setBreakdowns('publisher_platform, platform_position, impression_device')
.setInsightsEndpoint()
.setApiId('CAMPAIGN_ID_HERE')
.execute()
.then(console.log)
Returns a params object with helper methods attached for crafting FB Graph query strings. Note that using this helper module will automatically inject appsecretproof and token into your get parameters as needed for consuming data on the FB Graph API. As of v1.0.10 this is included on the base FBGraphUtils, but can be called standalone by using BaseParamFactory
import FBGraphUtilsFactory from 'facebook-graph-utils'
const FBGraphUtils = FBGraphUtilsFactory('TOKEN', 'APPSECRET')
const campaignBreakdownInsightsParams =
FBGraphUtils
.setLevel('campaign')
.setInsightsFields()
.setBreakdowns('publisher_platform, platform_position, impression_device')
.toGetParams()
//?appsecret_proof=XXXXX&access_token=TOKEN&date_preset=lifetime&limit=50&level=campaign&fields=ad_id ,account_currency,account_id,account_name,action_values,actions,ad_name,adset_id,adset_name,buying_type,call_to_action_clicks,campaign_id,campaign_name,canvas_avg_view_percent,canvas_avg_view_time,canvas_component_avg_pct_view,clicks,cost_per_10_sec_video_view,cost_per_action_type,cost_per_estimated_ad_recallers,cost_per_inline_link_click,cost_per_inline_post_engagement,cost_per_outbound_click,cost_per_total_action,cost_per_unique_action_type,cost_per_unique_click,cost_per_unique_inline_link_click,cost_per_unique_outbound_click,cpc,cpm,cpp,ctr,date_start,date_stop,estimated_ad_recall_rate,estimated_ad_recallers,frequency,impressions,inline_link_click_ctr,inline_link_clicks,inline_post_engagement,mobile_app_purchase_roas,objective,outbound_clicks,outbound_clicks_ctr,place_page_name,reach,relevance_score,social_clicks,social_impressions,social_reach,social_spend,spend,total_action_value,total_actions,total_unique_actions,unique_actions,unique_clicks,unique_ctr,unique_inline_link_click_ctr,unique_inline_link_clicks,unique_link_clicks_ctr, unique_outbound_clicks,unique_outbound_clicks_ctr,unique_social_clicks,video_10_sec_watched_actions,video_15_sec_watched_actions,video_30_sec_watched_actions,video_avg_percent_watched_actions,video_avg_time_watched_actions,video_p100_watched_actions,video_p25_watched_actions, video_p50_watched_actions,video_p75_watched_actions,video_p95_watched_actions,website_ctr,website_purchase_roas&breakdowns=publisher_platform, platform_position, impression_device
FBGraphUtils.getAllFbApiData(`https://graph.facebook.com/v2.10/CAMPAIGN_ID_HERE/insights${campaignBreakdownInsightsParams}`)
.then(console.log)
Returns an endpoint object with helper methods attached for crafting FB Graph urls. Note: as of v1.0.10 this is included on the base FBGraphUtils but can be used seperately by using makeApiEndpointUtils
//Note this is just an illustration, it's recomended to compose and use execute (see above example for execute)
import FBGraphUtilsFactory from 'facebook-graph-utils'
const FBGraphUtils = FBGraphUtilsFactory('TOKEN', 'APPSECRET')
const campaignBreakdownInsightsParams =
FBGraphUtils
.setLevel('campaign')
.setInsightsFields()
.setBreakdowns('publisher_platform, platform_position, impression_device')
.toGetParams()
const campaignInsightsEndpoint =
FBGraphUtils
.setInsightsEndpoint()
.setApiId('CAMPAIGN_ID_HERE')
.getApiEndpoint(campaignBreakdownInsightsParams)
//https://graph.facebook.com/v2.10/CAMPAIGN_ID_HERE/insights?appsecret_proof=XXXXX&access_token=TOKEN&date_preset=lifetime&limit=50&level=campaign&fields=ad_id ,account_currency,account_id,account_name,action_values,actions,ad_name,adset_id,adset_name,buying_type,call_to_action_clicks,campaign_id,campaign_name,canvas_avg_view_percent,canvas_avg_view_time,canvas_component_avg_pct_view,clicks,cost_per_10_sec_video_view,cost_per_action_type,cost_per_estimated_ad_recallers,cost_per_inline_link_click,cost_per_inline_post_engagement,cost_per_outbound_click,cost_per_total_action,cost_per_unique_action_type,cost_per_unique_click,cost_per_unique_inline_link_click,cost_per_unique_outbound_click,cpc,cpm,cpp,ctr,date_start,date_stop,estimated_ad_recall_rate,estimated_ad_recallers,frequency,impressions,inline_link_click_ctr,inline_link_clicks,inline_post_engagement,mobile_app_purchase_roas,objective,outbound_clicks,outbound_clicks_ctr,place_page_name,reach,relevance_score,social_clicks,social_impressions,social_reach,social_spend,spend,total_action_value,total_actions,total_unique_actions,unique_actions,unique_clicks,unique_ctr,unique_inline_link_click_ctr,unique_inline_link_clicks,unique_link_clicks_ctr, unique_outbound_clicks,unique_outbound_clicks_ctr,unique_social_clicks,video_10_sec_watched_actions,video_15_sec_watched_actions,video_30_sec_watched_actions,video_avg_percent_watched_actions,video_avg_time_watched_actions,video_p100_watched_actions,video_p25_watched_actions, video_p50_watched_actions,video_p75_watched_actions,video_p95_watched_actions,website_ctr,website_purchase_roas&breakdowns=publisher_platform, platform_position, impression_device
FBGraphUtils.getAllFbApiData(campaignInsightsEndpoint)
.then(console.log)
The package uses request-promise, bluebird Promises and CryptoJS by default. Any of these dependencies can be overridden. For example to create the FBGraphUtils using 'request' rather than 'request-promise' you can do the following:
import request from 'request'
import Promise from 'bluebird'
import CryptoJS from 'crypto-js';
import makeFBGraphUtilsFactory from 'facebook-graph-utils/facebook-graph-utils'
const defaultServices = {
request,
Promise,
CryptoJS
}
const FBGraphUtilsFactory = makeFBGraphUtilsFactory(defaultServices)
const FBGraphUtils = FBGraphUtilsFactory('TOKEN', 'APPSECRET')
Note: the only libraries tested are the default injected services.
yarn test
yarn publish
We use SemVer for versioning. For the versions available, see the tags on this repository.
(MIT License)
Copyright (c) 2017 Denim® mclark@denimlabs.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
A collection of composable utilities to make it easier to consume data from facebook graph and APIs
We found that @denimlabs/facebook-graph-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.