Facebook Marketing API limits - facebook-graph-api

I use marketing fb graph API through my fb app with developer level access. I need to basically get all data (info about campaigns, ad sets, stats, and so on) as often as possible. There are some limits and I'm reaching them pretty quickly calling graph marketing API. After a few hundred calls I'm stuck with err #17 - request limit reached.
My questions are:
is it possible and how to increase the limit
what's the efficient way of getting all data. I'm mostly interested in tracking changes (smth has been added/ updated/ deleted and stats), but first of course I need to gather all my marketing account data somehow.

Requesting each object for it's info / stats is going to hurt after a while. If you need detailed stats about engagement, social reach, impressions and such, you have a couple options:
The /reportstats endpoint is available for most objects and overs aggregation filters, specificity, column selecting and other useful things and can also be called to asynchronously generate a stats report for all of the objects you requests. This can even be done on an account level. You could easily retrieve a low-level aggregation of delivery stats for the entire tree of objects in your account or campaign.
Another more recent development in their API is the Insights endpoint, which is a centralized endpoint for retrieving stats as well and operates more like the rest of the graph API (request field names, filtering, preset, etc).
I recommend reading up on each for retrieving delivery stats for your ads api objects.
Additionally, if you're looking for the objects' attributes themselves, there are a couple options. The most useful one may be that you can request the graph api with no endpoint and a list of object ids in the params. The request would look like this graph.facebook.com/?ids=000000000. Furthermore, you can use facebook's fields query parameter to return attributes about that object. But, wait; there's more. Facebook's graph api offers field expansion for connected objects through this same query parameter. That is to say, you could request all campaigns' attributes, all ad sets' names and all ad sets' ads' names like so:
curl -G \
-d 'ids=00000000,111111111' \ # ids of campaigns
-d 'fields=name,adcampaigns.limit(50).fields(name),adgroups.limit(50).fields(name)' \
-d 'access_token=xxxxxxxxxx' \
https://graph.facebook.com/v2.4

Related

Fetching Facebook Ad spends grouped by campaign names

I wanted to fetch the daily ad spends in Facebook based on campaigns separately, ie, for each campaign with its spend.
I have tried with API call, but that gives state wise classification. How do I group based on campaign names?
"https://graph.facebook.com/v14.0/act_xxxxxx/insights?" + encodeURI("level=ad&fields=spend&access_token=FB_ACCESS_TOKEN&breakdowns=region,country&time_range={'since':'2022-08-09','until':'2022-08-09'}&filtering=[{\"field\":\"country\",\"operator\":\"CONTAIN\",\"value\":\"US\"}]&limit=100")
Campaigns and adsets has an insights field where you can read performance and spending metrics.
Get insights from campaigns endpoint
https://graph.facebook.com/v14.0/act_xxx/campaigns?fields=name,insights{spend}
you can use date filters with you calls to get lifetime spending.
you can also get spending from campaign adset insights field.
Check the official documentation
https://developers.facebook.com/docs/marketing-api/reference/ad-campaign/insights

feeding real time data into aws personalize

I want to feed real time data into aws personalize to build a recommendation engine. I've read online resources and in those guides, I could see that the training user-interaction data, user data and item data is provided in the beginning while creating the recommendation engine.
However, I have an app and I will gather data in the app and want to feed those realtime data into aws personalize. I want to know if building the recommendation engine is possible without providing any data at first and then stream real time data from my app later with the putevents, putItem and putUser api from aws-sdk? I'm quite new to this so I'm quite confused with this initial step
I want to know if building the recommendation engine is possible without providing any data at first and then stream real time data from my app later with the putevents, putItem and putUser api from aws-sdk?
Yes, it is possible. You just need to adjust the sequence of creating resources.
Interaction data is required for all Personalize recipes before a recommender can be created that provides recommendations. However, if you don't have interaction data (or enough data; see quotas and limits) to start with, you can create a dataset group and an interactions dataset, feed interactions to the dataset using the PutEvents API (see recording events page), and then create a domain recommender or custom solution when enough data has been ingested.
The minimum amount of interaction data (and potentially item metadata) required before you can train a model/recommender depends on the recipe that you select. Generally speaking, you will need 1000 interactions across 25 distinct users where each of those users has 2+ interactions. The domain recommenders also require specific event types. Check the docs linked above. The quality and relevance of recommendations will improve as you collect more data and retrain.

Paginate GetRecommendations API of AWS Personalize

I'm currently try to create a recommendation page which incorporates a infinite scrolling pagination (something like Instagram Explore) but could't find a way to do it with AWS SDK out of the box.
Is there any other way to fetch the data from AWS Personalize in a paginated way and ensuring the retrieved data not duplicate?
The GetRecommendations API for Personalize currently does not support pagination so the only way to use this API directly would be to fetch up to 500 items from the client in one call and then progressively reveal recommended items as the user scrolls. Or you could create an intermediate public API endpoint using something like API Gateway & Lambda that supports pagination and then lazily fetch and load recommendations for a user in a datastore like Redis. A Redis lrange or zrange to paginate.
The advantage of retrieving the max number of recommendations and then paginating over them is that they represent a snapshot of recommendations at a moment in time. Since Personalize will potentially adjust recommendations based on new interactions streamed into the service, recommendations could change from one call to GetRecommendations to the next. This could create a user experience where the same item appears to be duplicated because it drops down in relevancy between calls and shows up in multiple "pages" of results.

FB Graph API (Insights) Multiple Queries In One Request

I have a graph API call:
https://graph.facebook.com/v8.0/atc_48485453349353/insights/?date_preset=last_14d&fields=account_name,campaign_name,adset_name&level=ad&breakdowns=age,gender&limit=99999999&access_token=ACCESS_TOKEN
I get some data on an ad level. So this will return the maximum number of rows. However, since I'm operating at an ad level with level=ad. There are certain fields that I don't have access to. For example the date_start and date_stop of the campaign and adset level. At the ad level, I can't access the adset budget either.
I don't want to have to make 3 API calls. For all levels. level=campaign, then level=adset, then level=ad
Is there a way to form the request so I can do it all in one API call? (Including a way to get the adset budget in this request)

How to display all products without using ListMatchingProducts in the Amazon MWS Products API?

I have integrated the MWS API for my store. The issue is I was not able to get list of all products which I have submitted from feeds and also available products in Amazon store in account.
I have tried all the api of MWS no any api giving all products.
In Listmatchingproducts api it needs query parameter but for product listing there should not be query parameter required.
So for all product listing which api will be used and how?
In order for you to retrieve all of your products without input parameters, you can use the Reports API to request an inventory report or active listings reports or any of the report types here: http://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html#ReportTypeCategories__ListingsReports
You can call the Reports API just like the Products API, but there are extra steps involved. You first request the report using the RequestReport operation, then you'll get back a GeneratedReportId. Take that Id and call the GetReport operation and you'll get back the report once it's available. If you need more than a report, but need to work with the data in some other way, you can just write a routine in whatever language you're using to parse out the data in memory.
Have you seen the client libraries? They do most of the work already, just plug in your keys. https://developer.amazonservices.com/gp/mws/api.html/188-4747010-1589520?ie=UTF8&group=bde&section=reports&version=latest
Basically there is no specific API to call the product list available in your store. But you can get your products using Reports API (ReportType enumeration)
http://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html#ReportTypeCategories__ListingsReports
There is multiple steps involve in order to work with reports.Here is the steps that involve to get the product listing.
1-RequestReport
2-GetReportRequestList (includes the ReportId when done)
3-GetReport
Have you tried Scratchpad. its for UK marketplace.
https://mws.amazonservices.co.uk/scratchpad/index.html