How do I get the number of Followers gained and lost during a selected time range from Instagram API? - instagram

I need to get number of Followers gained and lost or just the total followers during a selected time range.
For example:
if I send a request to: https://api.instagram.com/v1/users/3/
I will get this Json:
{
"data":
{
"username": "kevin",
"bio": "CEO & Co-founder of Instagram",
"website": "",
"profile_picture": "https://instagramimages-a.akamaihd.net/profiles/profile_3_75sq_1325536697.jpg",
"full_name": "Kevin Systrom",
"counts": {
"media": 1419,
"followed_by": 1138347,
"follows": 643
},
"id": "3"
}
But I can't get the "followed_by" for a select time range
I read the Instagram api documentation and I can't find anywhere a Endpoint to do a request that I want.
in MEDIA I can pass MIN_TIMESTAMP and MAX_TIMESTAMP as parameters, but I am not looking for medias, I am looking for the number of followers.
I know It's possible because there is a website https://minter.io that gets every information since the beginning of the account.
PS: I already have the Authentication with OAuth 2.0

There is no API to do this, I think you have to keep a track of your follower count and update it every day. Setup a cron job to do this via API.
I just tried minter.io, I dont know how they show followers from day 1, I can definitely tell u it is fake and not accurate, I had about 1400 followers at some point and I removed them few months ago, so its back to 200 something, and minter.io does not show this at all. I think they just show a fake linear graph for historical data and going forward they keep a track of followers every day.

It is possible to use the field 'followers_count' on the User node to get a starting point. This gives the total number of followers at the time of the request. From there you could calculate a running total by subtracting the daily follower count from the Insights api that you mention.
Get current follower count:
curl -i -X GET "https://graph.facebook.com/v8/<user id>?fields=followers_count&access_token=EAACwX..."
https://developers.facebook.com/docs/instagram-api/reference/user
Get new followers for single day:
curl -i -X GET "https://graph.facebook.com/v8/<user id>/insights?metric=follower_count&period=day&since=2020-10-5T07:00:01&until=2020-10-06T07:00:00
https://developers.facebook.com/docs/instagram-api/reference/user/insights

Related

Youtube Data API Search Returning Repeating Items

(Duplicate of this question since I don't have enough rep to add a comment).
Essentially when using Search and using the page token to get more results, the results in the following pages tend to have results from the previous pages. The more pages you go through, the more and more repeating videos appear.
You can test this directly via the documentation which allows you to perform calls from there. Do a search query for anything, keep track of the video IDs in the results, wait a few seconds, and then do another query with the next page token, and repeat. It sometimes takes around 5 or so pages before a duplicate shows up. The same issue happens if you search for related videos instead of a query.
Is this intended behavior? I cannot seem to locate anything in the documentation mentioning this. I may be wrong, but I feel like this issue only started happening this month because I did not notice this behavior in an application I was working on around a month ago.
The Youtube API returns the response in a paginated manner. This means that if you use the search functionality, your search results will be available on different pages where each page has a different page token. The maxResults parameter determines the number of results on each page(default=50). To tackle this problem and return new/different responses with each call , pass the nextPageToken to your next API call.
For example, if your first API call looks like this :
GET https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=10&q=cricket&key=[YOUR_API_KEY]
Your API response would look like :
{
"kind": "youtube#searchListResponse",
"etag": "uN1c33JfiFaPBemlxN5kH8lSaHw",
"nextPageToken": "CAoQAA",
"regionCode": "IN",
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 10
},
To get the next 10 results of those 1000000, add pagetoken = nextPageToken to your query ,something like this :
GET https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=10&pageToken=CAoQAA&q=cricket&key=[YOUR_API_KEY]
AND VOILA!
{
"kind": "youtube#searchListResponse",
"etag": "NeaA5DLyr3YIaKdX5ZxETA3GfhY",
"nextPageToken": "CBQQAA",
"prevPageToken": "CAoQAQ",
"regionCode": "IN",
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 10
}
YOU GET THE NEXT 10 RESULTS!
THE FIRST PAGE WOULD NOT HAVE ANY PAGETOKEN, SO THE FIRST API CALL NEEDS TO BE MADE WITHOUT PAGETOKEN PARAMETER
Refer to the official documentation for more details:
https://developers.google.com/youtube/v3/docs/search/list

Google Photos API mediaItems list/search methods ignore pageSize param

I am attempting to do a retrieve of all media items that a given Google Photos user has, irrespective of any album(s) that they are in. However when I attempt to use either the mediaItems.list or the mediaItems.search methods, the pageSize param I am including in either request is either being ignored or not fully fullfilled.
Details of mediaItems.list request
GET https://photoslibrary.googleapis.com/v1/mediaItems?pageSize=<###>
Details of mediaItems.search request
POST https://photoslibrary.googleapis.com/v1/mediaItems:search
BODY { 'pageSize': <###> }
I have made a simple implementation of these two requests here as an example for this question, it just requires a valid accessToken to use:
https://jsfiddle.net/zb2htog1/
Running this script with the following pageSize against a Google Photos account with 100s of photos and 10s of albums consistently returns the same unexpected amount of result for both methods:
Request pageSize
Returned media items count
1
1
25
9
50
17
100
34
I know that Google states the following for the pageSize parameter for both of these methods:
“Maximum number of media items to return in the response. Fewer media
items might be returned than the specified number. The default
pageSize is 25, the maximum is 100.”
I originally assumed that the reason fewer media items might be returned is because an account might have less media items in total than a requested pageSize, or that a request with a pageToken has reached the end of a set of paged results. However I am now wondering if this just means that results may vary in general?
Can anyone else confirm if they have the same experience when using these methods without an album ID for an account with a suitable amount of photos to test this? Or am I perhaps constructing my requests in an incorrect fashion?
I experience something similar. I get back half of what I expect.
If I don't set the pageSize, I get back just 13, If I set to 100, I get back 50.

twitter api count more than 100, using twitter search api

i want to search-tweet related 'data' and count more than 100
this is python grammer
from twython import Twython
twitter= Twython(app_key=APP_KEY,app_secret=APP_SECRET)
for status in twitter.search(q='"data"',count =10000)["statuses"]:
user =status["user"]["screen_name"].encode('utf-8')
text =status["text"]
data = "{0} {1} {2}".format(user ,text,'\n\n')
print(data)
f.writelines(data)
So what you're trying to do uses the Twitter API. Specifically the GET search/tweets endpoint.
In the docs for this endpoint:
https://dev.twitter.com/rest/reference/get/search/tweets
We can see that count has a maximum value of 100:
So even though you specify 10000, it only returns 100 because that's the max.
I've not tried either, but you can likely use the until or max_id parameters also mentioned in the docs to get more results/the next 100 results.
Keep in mind: "that the search index has a 7-day limit. In other words, no tweets will be found for a date older than one week" - the docs
Hope this helps!
You can use the field next_token of the response to get more tweets.
Refer to these articles:
https://lixinjack.com/how-to-collect-more-than-100-tweets-when-using-twitter-api-v2/
https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/paginate
The max_id parameter is the key and it is further explained here:
To use max_id correctly, an application’s first request to a timeline
endpoint should only specify a count. When processing this and
subsequent responses, keep track of the lowest ID received. This ID
should be passed as the value of the max_id parameter for the next
request, which will only return Tweets with IDs lower than or equal to
the value of the max_id parameter.
https://developer.twitter.com/en/docs/tweets/timelines/guides/working-with-timelines
In other words, using the lowest id retrieved from a search, you can access the older tweets. As mentioned by Tyler, the non-commercial version is limited to 7-day, but the commercial version can search up to 30 days.

Nodejs Gmail OAuth API to get Users.threads: list

I want to get list of threads after a specific datetime, but couldn't find any way to do it.
I have stored the updated datetime in the database according to the last time the Gmail API was used to fetch the list of threads.
Then using that updated time I want to retrieve the list further.
The Gmail API allows you to list threads/messages after a specific timestamp with second accuracy.
Let's say you want to list threads with messages received after Friday, 22-Jul-16 00:00:00 UTC, you would write after:1469145600 in the q-parameter.
Request
GET https://www.googleapis.com/gmail/v1/users/me/threads?q=after%3A1469145600&access_token={YOUR_ACCESS_TOKEN}
Response
{
"threads": [
{
"id": "1561153ce695b9ab",
"snippet": "Infinite Elgintensity has uploaded Gym Idiots - Spread Eagle Rows & Mike O'Hearn 585-Lb. Squat A montage of gym fails with... Infinite Elgintensity has uploaded Gym Idiots - Spread Eagle Rows",
"historyId": "895071"
}
],
"resultSizeEstimate": 1
}

Can i play track in play.spotify.com?

My problem is, I want to search for a single songs ( or many single songs in a array) and Echonest will return me a Spotify ID in a foreign_ID. Then I can use this Spotify_ID to continue searching for a desired song in Spotify library.
In this example this returns Tracks : http://developer.echonest.com/api/v4/song/search?api_key=QR3H8MYBUZDYTDWUB&format=json&results=1&artist=the%20Carpenters&title=top%20of%20the%20world&bucket=id:spotify&bucket=tracks
{"foreign_release_id": "spotify:album:0RZyZDffrtXVREHqoREIuA"
, "catalog": "spotify",
"foreign_id": "spotify:track:4VdTKWly7revQ8VoncG43z",
"id": "TRUBERV144D15243BC"},
{"foreign_release_id": "spotify:album:3jMQ6qZZASytoRwVBSRou9",
"catalog": "spotify",
"foreign_id": "spotify:track:3NG65ZHLpDHQrEPMbqIhbS",
"id": "TRRIMLE144D120B851"},
{"foreign_release_id": "spotify:album:5PzGOu1yBtxDc7n8Dc0Oed",
"catalog": "spotify",
"foreign_id": "spotify:track:48Xjc1yYvAYikRHQxdyERF",
"id": "TRBFCHA147B6E38122"},
{"foreign_release_id": "spotify:album:0AictFxEiiyOtuZ9S2PnnD",
"catalog": "spotify",
"foreign_id": "spotify:track:4lEJYHkieQi5LfyFrN5bel",
"id": "TRTEGDO147B6E4E95A"}
When I attach the spotify id which i get from echonest's return to the play.spotify.com that becomes "play.spotify.com/track/4lEJYHkieQi5LfyFrN5bel" it doesn't work, i don't know why. When I attached to album or artist, it works "play.spotify.com/album/3jMQ6qZZASytoRwVBSRou9".
I want to ask one more question: can I stream one track (one song) directly from spotify into my web application after I use the command: GET "api.spotify.com/v1/tracks/{id}" to get url of the track(the song)?
The track plays for me when I go to: https://play.spotify.com/track/4lEJYHkieQi5LfyFrN5bel
The specific track is not available in any market any longer, which you can see if you check https://api.spotify.com/v1/tracks/4lEJYHkieQi5LfyFrN5bel
$ curl -s https://api.spotify.com/v1/tracks/4lEJYHkieQi5LfyFrN5bel | jq .available_markets
[]
However, there are many other tracks that has the same recording and Spotify should play one of those tracks instead. To see the one that client should play instead add market as a query parameter, in my case SE for Sweden. https://api.spotify.com/v1/tracks/4lEJYHkieQi5LfyFrN5bel?market=SE and check the uri attribute.
$ curl -s https://api.spotify.com/v1/tracks/4lEJYHkieQi5LfyFrN5bel?market=SE | jq -r .uri
spotify:track:4Hbj7GnBASAS6dUmsIMD6q
I can't imagine that you are in a market where there is no replacement for this track. I think it is a bug with the Spotify web player.

Resources