Instagram Search for a tag within particular date range - date

I am looking to retrieve results from instagram for a particular tag mytag , I tried using this API call,
https://api.instagram.com/v1/tags/{tag-name}/media/recent
but it only returned 33 results even though there are more results. This question can be considered an extension to this question: How To Search Instagram via API Query?
What is the way to return instagram results for a particular tag within a date range?
This may be done through the min_tag_id and max_tag_id which. Not sure how to convert my date time to min_tag_id or max_tag_id?

call the API with max_tag_id and min_tag_id like this:
https://api.instagram.com/v1/tags/{tag-name}/media/recent?client_id={CLIENT_ID}&max_tag_id=1378677250000000&min_tag_id=1375998850000000
max_tag_id and min_tag_id is epoch_time + "000000"
you still only get 20 per API call, use pagination to get all
Update: Instagram changed the tag_id, so date filter cannot be done
this way. Login on http://gramfeed.com and search for a hashtag and
you can do date/time filter, its a different hack implementation.

Related

Microsoft Graph Rest API - Filter by last X days

I have a rest URL that I am running against Microsoft Graph via POSTMAN and I'd like to know how to make the date filter check for records with activity in the last 90 days. My URL is this:
https://graph.microsoft.com/beta/users?$select=signInActivity&$filter=signInActivity/lastSignInDateTime%20le%202022-09-01
I do not want to use the hard-coded date like in this example or have to lean on something like powershell. Is there a way to calculate the date in the url or to tell the filter to do so? Something like this would be nice:
https://graph.microsoft.com/beta/users?$select=signInActivity&$filter=signInActivity/lastSignInDateTime%20le%20(today()-days(90))
Graph API does not support functions for working with date.
You can declare a property in Postman and set the property before the request is sent.
Example
The Graph API request is in a Postman collection. You can create a collection variable MyVar and use the variable in $filter query.
Then you can write a pre-request script in JavaScript and set the collection variable.
let d = new Date();
d.setDate(d.getDate()-90);
pm.collectionVariables.set("MyVar", d.toISOString().split('T')[0]);
Send the request and check console how the request looks like.
Resources:
Filter query operators

Facebook Graph API (v.3.1) Marketing API: use two paramaters with Campaign Insights

I'm trying to return campaign insights in the Facebook Marketing API and show the results aggregated for each day and broken down by country.
I'm trying
act_xxxx/?fields=campaigns{name,insights}&time_increment=1&breakdowns=country
but the country and time_increment paramaters don't seem to affect the results.
I've had success with EITHER time_increment of breakdowns if I don't use the ?fields paramater but then I'm not aggregating at the level I want and can still only use one paramater.
Can anyone suggest anything?
Thanks
James
Managed to figure this one out:
act_xxx/insights?fields=account_name,campaign_name,date_start,date_stop,spend,reach,impressions,cpc,inline_link_clicks,frequency,ctr,cost_per_inline_link_click,inline_link_click_ctr&breakdowns=country&time_increment=1&level=campaign
The key things I was missing were:
define the level of aggregation in the ?level paramater return the
Return insights edge before the ?fields paramater rather than through field
extension as I did in my example.
all you have to do is
act_xxxx?fields=campaigns{name,insights.time_range({"since":"2019-03-03","until":"2019-03-03"}).time_increment(1).breakdowns(country)}
This one fetches all campaigns name and insights between the date interval in day by day manner breaking down according to countries
you can use {} for subfields like
campaigns{ads{name,insights,adcreatives{image_url}}}
you can use . and () for parameters like; always make sure you use you use fields only after parameters like this order .(){}
campaigns.limit(1).time_range({"since":"2019-03-03","until":"2019-03-03"}).time_increment(1).breakdowns(country){ads{name,insights.time_range({"since":"2019-03-03","until":"2019-03-03"}).time_increment(1).breakdowns(country),adcreatives{image_url}}}

Retrieve the newly added comments from Facebook

Giving a PostId i'm trying to retrieve all the comments attached to this post by using the graphApi. Its simple to retrieve the comments for the first time, i just keep following the next link in the paging propertie of the api response.
But to keep this list of comments up to date i need to retrieve the newly added comments. I tried using the cursor After (stored from the last retrieved page) but it's not working as expected, using the parameter since in the query doesn't work either (seems that it is not supported by the endpoints /comments).
Can please someone gives me an alternative solution?
As i said 'since' is not supported by the endpoint '/comments' because the api use cursors for the pagination (next, after and befor fields).
The use of the cursor 'after' will not work neither, because the its value is valide for a short period of time (docs link)
So my solution was to use an ordred query to get the comments
https://graph.facebook.com/v2.6/[post-id]/comments/&filter=stream&order=reverse_chronological
, i save the created_timeof the first comment as last_update_time. Then the next time i execute my code i check for each comment the time when it has been created if it's grater than the last update time i save it
while (comment.created_time > last_update_time):
comments_list.add(comment)
comment = comments.next()
if (len(comments_list)>0):
last_update_time = comments_list[0].created_time

Filtering by action_target_id on Facebook Ads API

I am using the Facebook Ads API to try to filter out specific action target ids using the follwowing call:
(account-id)/reportstats?date_preset=yesterday&data_columns=["action_target_name","adgroup_id","adgroup_name","spend","actions","adgroup_objective"]&actions_group_by=["action_target_id", "action_destination"]&filters=[{"field": "action_target_id","type": "contains","value": 'insert id'}]
Every time I try to put in a specific ID, I get an empty data set back. Whenever I change the type to "not_contains", I get every piece of data returned. I've also tried the same with action_destination, but it keeps saying value needs to be numeric even though it a string.
It definitely seems like you can filter by action_target_id because when I tried to filter by something random, it told me that filter doesn't exist.
Can anyone help me please?
Unfortunately these values are nested under the actions fields of the results and filters only work on top level field values.

Proper REST formatted URL with date ranges

I have a REST URL to get all users formatted like this:
http://example.com/users
To get an individual user by id:
http://example.com/users/12345
To get all user's bids:
http://example.com/users/12345/bids
To get all user's bids between two dates:
http://example.com/users/12345/bids/?start=01/01/2012&end=01/31/2012
or should it be like this:
http://example.com/users/12345/bids/start/01012012/end/01312012
I'm leaning towards the 1st date range URL as start and end are not entities in the domain. What is the proper way to format a REST URL with a date range?
Thanks,
Tom
http://example.com/users/12345/bids?start=01-01-2012&end=01-31-2012
Have the query parameters on the same "level" as the bids (remove the slash before the question mark). But you would probably want to have support for if they only provide one query parameter. So if they only provided "start" then it would get all bids after that date, or if they only provided "end" it would get all bids before that date.
The reasoning being that query parameters are good for GETting a subset of results from a GET request. They don't go on another level because the next level is usually one specific item with a unique identifier.
I would go with http://example.com/users/12345/bids?start=2012-01-01&end=2012-01-31.
There shouldn't be a slash before the query string.
Avoid using slashes in the query string. It'll be easier that way.
If you use the path separator / to delimit the values you're likely to encounter numerous issues. If you decide you want the start and end dates to allow ISO formats e.g. 2021-10-12T01:00:00.000Z, 2021-10-01T18:00:00.000+05:00, those formats contain characters that will break the URL. Much better to use querystring parameters.
I'd recommend using the querystring and ISO format for dates so your URL will look something like this:
https://example.com/users/12345/bids?start=2022-08-08T00:00:00.000Z&end=2022-08-09T00:00:00.000Z
Your API method that retrieves by date range can then be differentiated from the GET request that retrieves all bids for the user, simply by using a different method signature that expects additional start and end date parameters in the request.
if example.com/users/12345 gets the user with id 12345, then to get all users by id it should be example.com/users with the id included in the response as a relationship. (usually a hyperlink to that resource).
Now to get them by date ranges it should be example.com/users/start=01-01-2012&end=01-31-2012
The 12345 part is the id of an individual user, it's a resource, therefore it should not be included to get the rest of the users.
As the name of the parameter it should be meaningful. start could mean anything, but start_date is more meaninful.