How to get ALL Instagram POSTs by hashtag with the API (not only the posts of my own account)
Asked Answered
U

4

16

How to get ALL Instagram POSTs by hashtag with the API (not only the posts of my own account)

I am trying to get all the instagram pictures tagged with a precise hashtag but I only receive my own developer account posts tagged with the hashtag.

I am currently working in local development environment, maybe that's the problem?

Furthermore, what is Sandbox mode, and what should I do to go "Real" mode ?

In the platform policy, it's written "You cannot use the API Platform to crawl or store users' media without their express consent." .

Does it mean that what I am trying to do is simply not possible ?

Thanks for your help

Unbridle answered 27/4, 2017 at 10:24 Comment(0)
U
28

You can get the posts in raw JSON by simply accessing this URL: https://www.instagram.com/explore/tags/summer/?__a=1

Then just use javascript/jquery to fetch the data an loop through the posts. You get 12 posts, and a variable to see if there are more pages.

Example of getting latest 6 posts:

$.get('https://www.instagram.com/explore/tags/summer/?__a=1', function (data, status) {
    for(var i = 0; i < 6; i++) {
        var $this = data.graphql.hashtag.edge_hashtag_to_media.edges[i].node;
        $('#container').append('<img src="'+  $this.thumbnail_resources[2].src +'">');
    }
});
Ungrateful answered 8/2, 2018 at 10:11 Comment(17)
Wow! Then what is their API for? Our app that want to grab hashtag content has been rejected (without reason) for three times now in the app review process.. How reliable is this url?Pyles
@JosFabre i have been using this method for a couple of years. I think it was made possible when facebook bought instagram, But in the time i have been using this method the URL never changed, but the response have changed one time.Ungrateful
I can get the post image and everything but how can I access to the profile? I can see the owner property but can't find any way to access to the profile with it. I appreciate your answer!Henhouse
@PhillipYS what do want to access?Ungrateful
@Ungrateful I got the answer from the question but do you know is there any way to get top media only? I can see there's is_top_media_only in the object but I can't way to make the property trueHenhouse
@PhillipYS so for the late answer. If you still want to get the top media you can, The result of the above url always give you the 9 more popular posts. you can find them under the object: edge_hashtag_to_top_postsUngrateful
@Ungrateful Hi. Sorry for butting in but I also needed this so thank you for posting it. Would you happen to know if it is possible to search multiple hashtags at once? Or implement an "and" and "or" search?Pol
@Ungrateful I also notice has_next_page and end_cursor attributes. Would you know how to access the succeeding pages?Pol
@Pol the URL endpoint doesn't have multiple hashtag support. So you have to do an ajax call for each hashtag. You can use has_next_page to make an if statement to determine if you should make another ajax call to the same hashtag. Then you add another parameter to your URL and put the end_cursoras value. Like this: https://www.instagram.com/explore/tags/{{ hashtag }}/?__a=1&max_id={{ end_cursor }} Hopes it helps, otherwise, let me know :)Ungrateful
@Ungrateful it works! Thank you so much! I was on the verge of giving up on FB/IG developer access so this really made my day. Thanks!Pol
@Pol I am glad I could help :)Ungrateful
@Ungrateful Awesome! Is there a way to also get the link for each image?Jambalaya
@FredK do you mean a link to the post? if so, you have to use the shortcode which is returned by the object: instagram.com/p/[ShortCodeHere]. Alternative i have made a little jQuery plugin that uses this method, You can find it here: github.com/kasperlegarth/instastory.jsUngrateful
Thanks @Ungrateful You know if is there an URL to get posts by hashtag AND by user/account?Jambalaya
@FredK, nope. You have to make a different request for each source. A request to get the hashtag posts and then another for a user's posts.Ungrateful
Hello, @Ungrateful This was really a life saver Thanks for posting, I think the response have been changed since you last posted do you know how can I get the posts of next pages?Preselector
Hi, @LalitVavdara sadly this method is no longer available due to CORS policy. You can no longer make a request from one domain to another like this.Ungrateful
W
5

When you register for API client, you will be sandbox mode (development/test mode), in this mode you will get only your and your sandbox user's data in API response.

Once you complete app, you have to submit for review to instagram, if approved then you can set app to Live mode, and then you will see all posts in API response.

P.S. Note that you have have public_content permission in oauth scope to get all posts

Wallaby answered 27/4, 2017 at 19:56 Comment(0)
D
0

you need to type hashtag search on the google and there you go for first Url which take you to the meta developer documentation. Where you can get all the details that how can we implement the hashtag search in your app. There you need to create

  1. Developer Account
  2. Create App
  3. Business verification

after these all done you have to get permission and feature from app review section on your dashboard and you get some credentials mention in the API documentation to do so.

Damiondamita answered 12/12, 2023 at 7:26 Comment(0)
F
-1

You can get Instagram public posts by one or several hashtags with Data365 API I am currently working on. In a request, you can specify the number of posts you want to receive. You can get up to 20,000 posts in one request. It is possible to define the period (from-to) for receiving posts and specify if you need comments and how much. You also can point out other parameters to customize requests based on your personal needs.

To retrieve posts by hashtag you can use the following queries.

POST request to create a task for downloading posts, on the example of bitcoins hashtag: https://api.data365.co/v1.1/instagram/tag/bitcoins/update?max_posts_count=10000&access_token=TOKEN

GET request to obtain a list of posts of 100 items each through pagination: https://api.data365.co/v1.1/instagram/tag/bitcoins/posts?max_page_size=100&access_token=TOKEN

Besides, you can set up posts auto-monitoring by hashtag. You need to indicate the auto_update_interval parameter in the request if you want all data to be updated automatically according to some defined time interval. With this function, you can receive posts by a given hashtag regularly.

More detailed info in API documentation here: https://api.data365.co/v1.1/instagram/docs#tag/Instagram-hashtag-search

I hope you find my comment helpful.

Fasta answered 18/1, 2022 at 19:28 Comment(2)
It looks like this answer requires a paid subscription to a service. It does not help answer the question.Parakeet
Hi @Michael, Im exploring Social listening API aggregators like data365.co, Is there any other tools available like this? Can we discuss further?Tanguay

© 2022 - 2024 — McMap. All rights reserved.