Facebook Api Graph Pull data from a timeframe - facebook

I am new to this stuff, I am trying to use Facebook api Graph to get the data for the last 30 days and link it to Klipfolio.
I am able to pull all the data but no matter what i try I can not seam to get FB to only return all of the data not just last 30 days or 7days.
am I able to a time frame parameters?
Any help would be appreciated, this is what I have to pull all the data,
/adaccounts?fields=amount_spent
Thanks

i don't use facebook adds so i can't exactly test with data . but facebook graph api supports time based pagination of the data . read the time based pagination section at the graph api v2.2 docs page. .
it provides with until and since parameters.
A time-paginated edge supports the following parameters:
until : A Unix timestamp or strtotime data value that points to the
end of the range of time-based data.
since : A Unix timestamp or
strtotime data value that points to the start of the range of
time-based data.
i checked it with end points like
me/feed?until=10/11/2011
and it works as expected . so test the parameter for your required data .

Related

How to get Height data given during registration from Googlefit REST Apis

I am new to google fit rest APIs and I have been trying to calculate BMI of a user for my project.
So, when the user authorizes to my application at that time I get data for the last 30 days (historical data for some calculation). From then on I extract data periodically this way I always get the latest weight data.
But the issue comes in the scenario when the user has been using google fit way before authentication because I wouldn't know the exact date I should pass as parameter to extract height data.
The aggregate data type accepts the date range of only 90 days, else it returns the error as aggregate duration too large . But the user's height data could be as old as 2/3 years.
I also looked at the option of custom data types, but there again I don't know the exact date range to make an API call.
Is there any way that I can either get the user's joining date (the date he/she registered to Google fit) because a user has to provide height during registration or if I could somehow get data under About you (Gender, DoB, Weight, Height) in Profile tab
Or If I could get the calculated BMI data point directly from API.
Any help would be highly appreciated.

What time does the Graph's Insights API refresh the attributes with day as the aggregation period?

For example,
https://developers.facebook.com/docs/graph-api/reference/v2.11/insights
For the aggregation period 'day', Does anyone know at what time does Facebook refresh that value?
I remember reading it to be around 8am, but I can't remember if it was accurate or where I read it.
When you check out the endtime you get inside the values (Graph API Explorer request for me?fields=insights.metric(page_stories); supply your own page access token), for all three periods (day/wekk/days_28) it is of the form
2018-02-19T08:00:00+0000
Same time portion in each case.

Retrieving Microsoft Live calendar events between 2 dates

I'm currently working on requesting a list of events between 2 dates via Microsoft Live's REST API. I am able to pull back a list of events through the following request URL:
https://apis.live.net/v5.0/me/events
However, this returns a list of events that does not have any specific date frame. For example, I'd want to call a request similar to this:
https://apis.live.net/v5.0/me/events?startDate=2015-02-15&endDate=2015-03-15
I haven't been able to find any useful Microsoft documentation in their disorganized mess of "documentation", so my questions are:
1 - What changes need to be made to the first endpoint above for something like this to work?
2 - What time format does Microsoft use for this kind of request?
Thanks!
I finally found the answer in the middle of a Microsoft documentation page.
Get a limited number of events based on their starting and ending times in Coordinated Universal Time (UTC) format by using the start_time and end_time parameters
To answer my own questions:
#1 - The following endpoint works:
https://apis.live.net/v5.0/me/events?start_time=2015-02-15T00:00:00Z&end_time=2015-03-15T00:00:00Z
#2 - The time format is as follows:
yyyy-MM-dd'T'HH:mm:ss'Z'

paginated response Facebook API

In the Faceboook API, is there a way to get paginated API responses in reverse order? Or take only recent results or something?
Using the "next" link as discussed here (https://developers.facebook.com/docs/graph-api/using-graph-api/v2.1#paging), I can click through, but if there's a ton of results since all the way from 2013, that takes very long.
You can use time based pagination, this is from facebook documentation:
Time-based Pagination
Time pagination is used to navigate through results data using Unix timestamps which point to specific times in a list of data.
When using an endpoint that uses time-based pagination, you will see the following JSON response:
{
"data": [
... Endpoint data is here
],
"paging": {
"previous": "https://graph.facebook.com/me/feed?limit=25&since=1364849754",
"next": "https://graph.facebook.com/me/feed?limit=25&until=1364587774"
}
}
A time-paginated edge supports the following parameters:
until: A Unix timestamp or strtotime data value that points to the end of the range of time-based data.
since: A Unix timestamp or strtotime data value that points to the start of the range of time-based data.
limit: This is the number of individual objects that are returned in each page. A limit of 0 will return no results. Some edges have an upper maximum on the limit value, for performance reasons. We will return the correct pagination links if that happens.
next : The Graph API endpoint that will return the next page of data.
previous : The Graph API endpoint that will return the previous page of data.

Can response data from core reporting api be grouped?

Explanation:
I am able to query the Google Core reporting APIv3 using the client library to get data on pageviews for specific URLs of a website I am working on. I want to get data(pageviews) for each day within a specified range. So far I am simply looping through the range, sending individual request to the API. in each request I am setting the same value for the start date and the end date.
Problem:
Obviously this gets the job done, BUT it is certainly not the best way to go about it. Because, assumming I want to get data for the past 3 months for each of about 2000 URIs. Then I will need 360000 number of requests and that value is well over the limit quota defined by Google.
Potential solution: So one way I thought of solving this issue is probably to send a request setting start-date and end-date to be a week apart but the API will return a sum of the values rather than the individual values.
main question: So is there a way to insist that these values should not be added up and returned as a sum but rather returned (as associative array or something like that) separately for each.
I hope the question is clear and that there is a solution! Thank you!
Very straightforward:
Metric: ga:pageview, Dimension: ga:date, Set a filter for your pagepath, and set a start-date and end-date.
Example:
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3Axxyyzz&dimensions=ga%3Adate&metrics=ga%3Apageviews&filters=ga%3Apagepath%3D%3D%2Ffaq.html&start-date=2013-06-27&end-date=2013-07-11&max-results=50
This will return the pageviews for that the faq.html& page for each day in the time-frame.
You should check out the QueryExplorer. Great tool to find out how to structure queries.