I'd like to get Insights data before 2010-04-02, but it seems to be impossible to retrieve via the Graph API or FQL query. If you make a Graph API request spanning over 2010-04-02 you will get results starting at 2010-04-02 and going forward with the rest simply missing. Can any one explain this or have a way to get around this limitation?
Here is an example of the problem: http://developers.facebook.com/tools/explorer/?method=GET&path=2439131959%2Finsights%2Fapplication_active_users%3Fsince%3D2010-03-28%26until%3D2010-04-10%26date_format%3DY-m-d
There should be results from 2010-03-28 to 2010-04-10, but you only get 2010-04-02 and onwards.
{
"data": [
{
"id": "2439131959/insights/application_active_users/day",
"name": "application_active_users",
"period": "day",
"values": [
{
"value": 172118,
"end_time": "2010-04-02"
},
{
"value": 177263,
"end_time": "2010-04-03"
},
{
"value": 176568,
"end_time": "2010-04-04"
},
{
"value": 190725,
"end_time": "2010-04-05"
},
...
Maybe your insights were a "victim" of this: https://developers.facebook.com/docs/reference/fql/insights/
We are deprecating some old insights. These metrics are marked as
deprecated throughout this document. After 12/21/2011, data for these
metrics won't be available prior to 07/19/2011 -- please download this
data before this 12/21/2011. These insights will be completely removed
from API after 02/15/2012.
Related
I'm trying to get the ad spend and mobile app installs for my app using the Facebook Graph API v2.11 for marketing. In the Graph API Explorer, when I try
/act_<my account>/campaigns?fields=insights{actions,spend}&time_range={'since':'2017-07-07','until':'2017-12-12'}
In the output, under "insights", I get an object of this type:
"data": [
{
"actions": [
{
"action_type": "comment",
"value": "3"
},
{
"action_type": "like",
"value": "33"
},
{
"action_type": "link_click",
"value": "1531"
},
{
"action_type": "mobile_app_install",
"value": "1049"
}
],
"spend": "8621.03",
"date_start": "2017-10-28",
"date_stop": "2017-11-26"
}
]
If I want it to fetch only the actions where action type is "mobile_app_install", how can I further filter my query?
There is possible to filter that on Facebook side just call it like that:
/act_<yourAdAccount>/insights
?level=campaign
&fields=actions,spend
&time_increment=all_days
&time_range={'since':'2017-07-07','until':'2017-12-12'}
&filtering=[{field: "action_type",operator:"IN", value: ['mobile_app_install']}]
&use_account_attribution_setting=true
I have gone through the documentation as well as the adsinsights.py file on github but I cannot find a way to limit the number of action_types returned. You will simply have to do the filtering after you have retrieved the data from the api.
https://developers.facebook.com/docs/marketing-api/insights/parameters
https://github.com/facebook/facebook-python-ads-sdk/blob/master/facebookads/adobjects/adsinsights.py
I have been working on a Facebook app for the last couple of weeks. I have successfully posted data to Facebook's Graph API but I have been struggling to get back specific fields. I am using the API explorer to test my various GET attempts. Here's an excerpt of the data that is returned with the api call: me/g_music:listen_to?fields=data
{
"data": [
{
"data": {
"song": {
"id": "355308601243965",
"url": "https://g8-music.herokuapp.com/object/song.php?title=Pierce+The+Veil+-+Bulls+in+the+Bronx&description=Played+On+G8-Music+for+Windows+8.&image=http%3A%2F%2Fuserserve-ak.last.fm%2Fserve%2F174s%2F78366946.jpg",
"type": "g_music:song",
"title": "Pierce The Veil - Bulls in the Bronx"
}
},
"id": "245964195537372"
},
{
"data": {
"song": {
"id": "365613963536278",
"url": "https://g8-music.herokuapp.com/object/song.php?title=Pierce+The+Veil+-+Kings+for+a+Day+%28feat.+Kellin+Quinn%29&description=Played+On+G8-Music+for+Windows+8.&image=http%3A%2F%2Fuserserve-ak.last.fm%2Fserve%2F174s%2F78366946.jpg",
"type": "g_music:song",
"title": "Pierce The Veil - Kings for a Day (feat. Kellin Quinn)"
}
},
"id": "245961632204295"
},
I am attempting to get the value of title but have been unsuccessful so far.
If I try something like: me/g_music:listen_to?fields=data.data... I receive an exception which tells me that "Subfields are not supported by data".
I am relatively new to the graph API so I'm most likely missing something obvious.
You are not missing anything. I verified this through the Graph API Explorer.
Subfields are not supported by data
But you have the whole data, simply fetch the title from the array.
I have been trying to get historical data for Facebook pages. I was wondering how to determine how far back I can go.
So I know I can go one month back. Is this a rolling window? I also would like to know how far I can go back and not get an api exception like follows.
{
"error": {
"message": "Unsupported operation",
"type": "FacebookApiException",
"code": 100
}
}
Is it possible to get all the historical insight data for a given fan page that I have access to.
Thanks and any suggestions that might help with understanding how to do this cleanly and robustly are also welcome.
Start with 30 days ending on the current day, e.g.
/278905338821044/insights/page_fans/lifetime?since=30 days ago&until=now
The response will have the last 30 days' data, and you can iteratively go through the 'previous' links in the paging structure at the end to go back into the past
{
"data": [
{
"id": "278905338821044/insights/page_fans/lifetime",
"name": "page_fans",
"period": "lifetime",
"values": [
{
"value": 1432,
"end_time": "2012-09-19T07:00:00+0000"
},
//snip
{
"value": 1438,
"end_time": "2012-10-16T07:00:00+0000"
}
],
"title": "Lifetime Total Likes",
"description": "Lifetime The total number of people who have liked your Page. (Unique Users)"
}
],
"paging": {
"previous": "https://graph.facebook.com/278905338821044/insights/page_fans/lifetime?since=1345405748&until=1347997748",
"next": "https://graph.facebook.com/278905338821044/insights/page_fans/lifetime?since=1350589748&until=1353181748"
}
}
I am trying to retrieve the "Place" field of a Facebook Graph Post object from a Facebook friend. After obtaining an access token with the friends_status and read_stream permissions, I request from the Graph API like so:
http://graph.facebook.com/[user_id]_[post_id]
What is returned are some of the fields described in the Graph API docs for Post:
{
"id": "1164358582_2458311174854",
"from": {
"name": "Joe Blo",
"id": "1164358582"
},
"message": "Is pretty bummed today",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
},
{
"name": "Like",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
}
],
"type": "status",
"application": {
"name": "Facebook for Android",
"id": "350685531721"
},
"created_time": "2011-11-20T03:23:04+0000",
"updated_time": "2011-11-20T12:12:49+0000",
"comments": {
"data": [
{
"id": "1164358582_2458311174852_2962531",
"from": {
"name": "Sue Candy",
"id": "1056617421"
},
"message": "OMG I'm so sorry!!!",
"created_time": "2011-11-20T03:25:06+0000"
}
],
"count": 1
}
}
This is all fine and dandy, except for the fact that when I see this Post within my Facebook stream, it also shows a location accompanying the post:
9 hours ago near El Reno, OK
I expected the El Reno, OK Place object returned as a field within this Post, but I don't see it.
In the Facebook Graph API Explorer, I've tried enabling almost every permission and I am not seeing any difference in the response (no "Place" field returned). Am I going about this incorrectly?
Not 100% sure but I think you can only get the "place" info if it is of type "checkin". I totally get where you are coming from, I wondered about that myself.
https://developers.facebook.com/tools/
Try the Graph API Explorer Tool if you haven't already looked at it.
I've been testing graph API and ran into a problem. How can I get like count from photos of a page/group?
I'm administrator/creator of a group. When entering in https://developers.facebook.com/tools/explorer/ certain photo ID from that group it brings almost all data, even comments, but not the like count. For like part it needs (according to docs) access token despite the fact that anyone can access that info.
How to get access token of my page/group with required permissions and how to use it to get info I need?
If possible I would like to get JSON from a single address if it is possible.
This is possible with a page (even without an access token!) and here's how:
Visit the page on the graph
Get the page's id by going to the page's url:
https://www.facebook.com/pages/platform/19292868552
The number on the end of the URL is the page's id. Take that id and use it with the graph explorer (here) or just visit it directly.
Visit the page's albums
Now appending albums to that url will give you all the albums the page has, including wall photos:
https://graph.facebook.com/19292868552/albums
The output looks like this:
{
"data": [
{
"id": "10150160810478553",
"from": {
"name": "Facebook Platform",
"category": "Product/service",
"id": "19292868552"
},
"name": "Bringing Operation Developer Love to Europe",
"description": "Blog post: http://developers.facebook.com/blog/post/479\n\nVideos and presentations uploaded here: http://developers.facebook.com/videos/",
"location": "Berlin, Paris, London",
"link": "https://www.facebook.com/album.php?fbid=10150160810478553&id=19292868552&aid=285301",
"cover_photo": "10150160811078553",
"count": 32,
"type": "normal",
"created_time": "2011-04-06T23:05:44+0000",
"updated_time": "2011-04-06T23:33:20+0000",
"comments": {
..... etc ....
Selecting an album
For each object in the data array there is an id and a name. Using these two fields you can select the album that contains the photos you want. The first album in this result is "Bringing Operation Developer Love to Europe". Lets look at this albums photos.
Seeing Photos
If you've followed the answer up to this point the next step should be fairly obvious. Use the id for the album you want and append photos to the graph url:
https://graph.facebook.com/10150160810478553/photos
Seeing a Photo's likes
Much like selecting an album, simply use an id in the output of the above step and append likes to the url to see a photos likes:
https://graph.facebook.com/10150160813853553/likes
Output:
{
"data": [
{
"id": "1163036945",
"name": "Aditya Pn"
},
{
"id": "1555885347",
"name": "Nadin M\u00f6ller"
},
{
"id": "100001643068103",
"name": "Umut Ayg\u00fcn"
},
{
"id": "100000165334510",
"name": "Alessandra Milfont"
},
{
"id": "100001472353494",
"name": "Sayer Mohammad Naz"
},
{
"id": "1051008973",
"name": "Jenson Daniel Chambi"
},
{
"id": "100000233515895",
"name": "Ruby Atiga"
},
Using this output you can simply count the number of entries in the data array to get the like count.
Note that all of this is possible from using the graph explorer by clicking on ids in the output box and the connections sidebar (except for the last /likes connection, which will hopefully be added soon. I hope this helps. Also, you do not need an access token to do any of this because pages are public. Hope this helps!
You can get the comments/likes count without having to paginate through all likes by using the fields parameter in combination with likes.limit(1).summary(true). For example, a search api query for pizza below will give you all public posts and their likes count summarized:
https://graph.facebook.com/search?q=pizza&type=post&fields=id,name,likes.limit(1).summary(true)
results (truncated):
{
"data": [
{
"id": "47883936273_659693910762305",
"name": "Instagram",
"created_time": "2014-02-16T01:15:29+0000",
"likes": {
"data": [
{
"id": "100002243084532",
"name": "Yvette Martin"
}
],
"paging": {
"cursors": {
"after": "MTAwMDAyMjQzMDg0NTMy",
"before": "MTAwMDAyMjQzMDg0NTMy"
},
"next": "https://graph.facebook.com/47883936273_659693910762305/likes?limit=1&summary=1&after=MTAwMDAyMjQzMDg0NTMy"
},
"summary": {
"total_count": 13682
}
}
},
{
"id": "136336876521150_314001148754721",
"name": "Pizza Box Turns into Plates & Storage Unit!",
"created_time": "2014-02-15T21:20:00+0000",
"likes": {
"data": [
{
"id": "100005373008864",
"name": "Liliana Campoli"
}
],
"paging": {
"cursors": {
"after": "MTAwMDA1MzczMDA4ODY0",
"before": "MTAwMDA1MzczMDA4ODY0"
},
"next": "https://graph.facebook.com/136336876521150_314001148754721/likes?limit=1&summary=1&after=MTAwMDA1MzczMDA4ODY0"
},
"summary": {
"total_count": 2792
}
}
}
/me/feed returns a LIKES field
I used a solution where I simply find the number of items in the array which display LIKES
Object.keys(item.likes.data).length
This returns the "length" of an object -- which is equal to the number of likes.
http://graph.facebook.com/223766074374957
there is a likes property in the response
{
"name": "Bejeweled Blitz",
"is_published": true,
"website": "https://apps.facebook.com/bejeweledblitz/",
"username": "bejeweledblitz",
"products": "Bejeweled Blitz\nBejeweled\nPlants vs. Zombies\nPeggle\nZuma\nChuzzle\nBookworm Adventures\n \nFor a complete list, please visit www.popcap.com\n ",
"about": "We're the award-winning hit, Bejeweled Blitz! The lightning-fast puzzle game where you have just 60-seconds to match as many gems as you can! Start Blitzing now!",
"general_info": "Speed is the name of the game in Bejeweled Blitz! Bejeweled Blitz is a speedier take on the classic Bejeweled match-3 gem game mechanic. Your goal is to make as many matches as you can in 60-seconds to really make your score soar! But you won't be going it alone! There are special ways to enhance your Bejeweled Blitz game - like Boosts (power-ups like Scrambler, which moves all the gems around the board or +5 seconds, to add 5 seconds more gem-matching time!) and the popular, Rare Gems. Rare Gems are like extra-special power-ups that can REALLY take your game to the next level!",
"talking_about_count": 22487,
"category": "App page",
"id": "223766074374957",
"link": "https://www.facebook.com/bejeweledblitz",
"likes": 5796324,
"cover": {
"cover_id": 383412771743619,
"source": "http://sphotos-c.ak.fbcdn.net/hphotos-ak-ash4/s720x720/417018_383412771743619_1056862875_n.jpg",
"offset_y": 0
}
}