April 9, 2026

How to use Instagram API to pull photos based on hashtag

To pull photos by hashtag using the Instagram API, you need a Facebook Developer account, an approved Instagram Graph API access, and the ig-hashtag search endpoint. Query hashtags via /ig-hashtags?q={hashtag}, retrieve the hashtag ID, then call /recent_media to fetch associated photos. This guide also covers hashtag strategies for influencer and marketing campaigns, and how Phyllo simplifies Instagram API integration.

To pull Instagram photos by hashtag, use the Graph API's /ig_hashtag_search endpoint to get a hashtag node ID, then query /{hashtag-id}/top_media or /{hashtag-id}/recent_media. This requires an Instagram Business or Creator account and a Meta Developer App with OAuth 2.0 authentication.

Meta's CEO Mark Zuckerberg confirmed Instagram crossed 3 billion monthly active users in September 2025, making it one of only three platforms globally to reach that milestone. Businesses and influencers may reach and develop their audiences on it. Hashtag search for searching Instagram photos is strong. It help people identify and publish related content material and promote your own content.

This blog article shows how to utilize the Instagram API to fetch Instagram photos through hastags via navigating various social media accounts. We'll also talk about hashtags in Instagram influencer and marketing campaign and how Phyllo can assist with Instagram API Integration.

Downloadable API guide for Developers

Importance of Hashtags in Instagram Influencer Marketing

Posts with at least one hashtag average 12.6% more engagement than those without. Here’s why Instagram hashtags are so crucial in the world of influencer marketing:

Reach Out to the Right Audience on Instagram:

  • Instagram page algorithms and users utilise a particular hashtag to identify the most recently published photos based on interests.
  • By using the specific tag and Instagram API, you can connect with users who are looking for ways to promote their brand.
  • According to 2025 Sprout Social influencer marketing data, 43.6% of Instagram influencers' audiences are between the ages of 25 and 34, making this the largest segment, with 28.92% in the 18–24 bracket, and they are using specific hashtags to view most popular photos or specific location.

Location-Based Content Becomes Easier:

  • Hashtags enable Instagram algorithms to segment content intended for a specific target audience.
  • By using location-based hashtags, you can promote your products and services in specific areas, districts, and cities. Images that are posted geographically gain better visibility.
  • As a result, when your audience searches for postings in their region, they will come across your stuff.

Cost-Effective Instagram Influencer Marketing:

  • Hiring an Instagram influencer to promote your business allows you to reach millions of users.
  • You can avoid the high costs of traditional advertising methods like billboards.
  • By leveraging hashtags and Instagram API, you can promote your services without having to pay thousands.
Instagram API Integration

How Instagram APIs Can Help You Pull Photos Based on Hashtags with PHP

If you want to retrieve photos from Instagram that have a specific hashtag, you can leverage the Instagram API. The steps below walk through the PHP approach. If you prefer Python, check out our guide on how to use the Instagram API with Python for a language-specific walkthrough. Here's a step-by-step guide on how you can accomplish this:

Register as a developer on the Instagram Developer Platform:

Create an app and obtain an app ID and app secret:

  • Create an app on the Instagram Developer Platform and acquire an app ID and app secret. These credentials will be used for authentication purposes.

Authenticate the app and obtain an access token:

  • Make an API request to the Instagram API with your app ID, app secret, and grant type to retrieve an access token. This token will grant you permission to access the API's endpoints.

Utilize the access token to retrieve photos with the specified hashtag:

  • Construct an API request URL using the access token and the desired hashtag.
  • After using access token, send a request to the Instagram API with the constructed URL and receive the response containing the photos.

Here's an example of PHP code that demonstrates how to use the Instagram API to pull photos based on specific hashtag's node:

Requirements, Uses, and Limitations of Hashtag Search

Prerequisites for Hashtag Search

To effectively employ the Hashtag Search on Instagram API, certain criteria must be satisfied:

  1. App Review Approval: The application must be reviewed and granted approval for the Instagram basic permission and the Instagram Public Content Access feature. App review is just one layer of how Instagram governs data access. For a deeper breakdown, read our guide on how Instagram controls third-party API access and what it means for developers building on the platform.

Hashtag Search API Endpoints

The Hashtag Search of Instagram API is structured around several primary nodes and edges:

  1. GET /ig_hashtag_search — Utilize this endpoint to obtain a unique node ID for a specific hashtag.
  2. GET /{ig-hashtag-id} — This endpoint delivers data related to a given hashtag.
  3. GET /{ig-hashtag-id}/top_media and GET /{ig-hashtag-id}/recent_media — These endpoints retrieve the most popular and most recently published media respectively, tagged with a specific hashtag.
  4. GET /{ig-user-id}/recently_searched_hashtags — This endpoint identifies the unique hashtags that an Instagram Business or Creator Account has searched for within the current week.

Each endpoint comes with its own set of supported fields, parameters, and usage requirements, outlined in the reference documentation.

Typical Applications of Hashtag Search with Instagram API

Retrieving Media Tagged With A Specific Hashtag

To gather all photos and videos associated with a specific hashtag with Instagram API , start by using the /ig_hashtag_search endpoint. This should include the hashtag in question and the ID of the Instagram Business or Creator Account initiating the query.

For instance, to search for media tagged with "#coke" on behalf of the Instagram Business Account with the ID 17841405309211844, you would perform the following query:

Query

This would return the ID for the "#Coke" hashtag node, which can then be used to query its /top_media or /recent_media edge to obtain a collection of media objects tagged with "#coke". For example:

Returning the ID for the #Coke

Constraints of Hashtag Search

While the Hashtag Search via Instagram API is a powerful tool, it does come with certain limitations:

  • Query Restrictions: An Instagram Business or Creator Account can query a maximum of 30 unique hashtags within a rolling, 7-day period. Once a hashtag is queried, it counts towards this limit for 7 days. Repeated queries of the same hashtag within this period do not impact the limit or reset the 7-day timer. Also, the Instagram Graph API also enforces a limit of 200 requests per hour per user token, and API calls returning HTTP 429 (Too Many Requests) errors reset after the hourly quota.
  • Data Privacy: Responses will not contain personally identifiable information.
  • Interaction Limitations: Users are not permitted to comment on hashtagged media objects discovered via the Instagram API.
  • Unsupported Features: Hashtags on Stories, and emojis in hashtag queries, are not supported by the Instagram API.
  • Content Moderation: The Instagram API will return a generic error for requests containing hashtags deemed sensitive or offensive.

Understanding these prerequisites, application possibilities, and constraints of the Hashtag Search API allows for its effective and responsible usage.

Recommended Read: How To Add Instagram API To Your App Or Website?

How Can Phyllo Help with Instagram API to pull photos based on hashtag

Instagram API to pull photos based on hashtag

Phyllo's Instagram API, with its simple and efficient approach to creator data, facilitates streamlined integration with multiple social media platforms — eliminating the need for developers to individually establish connections with YouTube, TikTok, Patreon, Spotify, and Instagram separately. Instead, it offers scalable and trustworthy integrations, enabling developers to work with a single, easy-to-integrate API. Phyllo can provide a wealth of creator data, including:

Phyllo Connect SDK for Instagram: Empowering the Creators

Phyllo Connect SDK for Instagram

Phyllo Connect SDK aims to foster trust among creators by educating them about the connection process, Phyllo's role, and the account information collected post-login. It commits to full transparency and seeks user consent before sharing details with the company. It also provides users with control over their connected account with an option to disconnect at any point.

Overcoming Challenges with Instagram Login Flows : While some platform login flows are seamless, like Twitter, others like Instagram can be more challenging. Instagram login requires connection via Facebook and a professional Instagram account linked to a Facebook page. Phyllo handles these requirements by educating creators before and after login, enhancing connection success rates for Instagram.

Instagram Stories and Graph APIs: Instagram stories represent a leading content format. Unfortunately, their engagement metrics are not publicly accessible and cannot be obtained through third-party scrapers. However, Instagram's Graph APIs, which are covered by Phyllo, provide these metrics, enabling Phyllo to deliver engagement data for photos posted to Instagram Stories. Learn More everything you need to know on Instagram Scraping

Related Read: Instagram Engagement Metrics: Why You Shouldn’t Miss These

Phyllo vs. Third-Party Aggregators for Instagram Data

Instagram's Graph API provides Phyllo with high-quality creator data. It complements the platform and provides a better data flow than data scraping. Phyllo surpasses third-party aggregators with 24 hours or fewer refresh frequency. Webhooks for real-time creator data updates and Instagram APIs for audience data eliminate the need for approximations.

Building Features Using Instagram user Data

Businesses can use creator data of Instagram app in myriad ways to create impressive products. Here are some examples:

  • Automated Verification: Phyllo provides a consented data pipeline that helps creators in Instagram app authenticate their identity and allows developers access to verify a creator's identity, income, and engagement across multiple platforms.
Third party aggregator for Instagram Data
  • Influencer Marketing: Brands can utilize Phyllo's Identity API to access creators' profile-level information, followers, subscribers, and other reputation metrics. This helps them assess a creator's value and ensures they collaborate with trusted creators rather than fraudsters.
  • Creator Tools: Phyllo's data pipeline aids in resolving identity issues on creator tools platforms, ensuring fans can confidently engage with their favorite creators.
  • Fintech: Phyllo's data can be used to authenticate a creator's identity, enabling fintech companies to extend financial services to the right individuals.
  • Web3: By verifying NFT creators' identities and reputations, Phyllo ensures fans are purchasing from genuine artists, thereby enhancing the overall trust in the web3 ecosystem.

Also read: How Beacons uses Phyllo to create the perfect media kit for creators to be successful

Conclusion

Hashtags are crucial for influencer marketing, enhancing content discovery and audience engagement. Instagram APIs allow businesses to pull photos based on these hashtags, providing valuable, marketing insights too. However, understanding the API's requirements and limitations is essential. Phyllo, an integrative tool, simplifies this process by providing a single API that accesses creator data across various social media platforms, including Instagram. By leveraging hashtags, Instagram APIs, and integrative tools like Phyllo, businesses and creators can maximize their Instagram marketing strategies' effectiveness and reach.

Related Read:

Frequently Asked Questions

1. Can you use the Instagram API to pull photos based on a hashtag?

Yes, but with conditions. The Instagram Graph API provides a Hashtag Search feature that lets Instagram Business or Creator Accounts retrieve photos and videos tagged with a specific hashtag. Your app must first pass Instagram's App Review and be approved for the Instagram Public Content Access feature before you can use these endpoints.

2. What are the API endpoints used to search Instagram photos by hashtag?

There are three main steps involved. First, call GET /ig_hashtag_search to retrieve the unique node ID for your target hashtag. Then use either GET /{ig-hashtag-id}/top_media to fetch the most popular posts or GET /{ig-hashtag-id}/recent_media to retrieve the latest ones. All requests require a valid access token from an authenticated Instagram Business or Creator Account.

3. How many hashtags can you search using the Instagram API per week?

An Instagram Business or Creator Account can query a maximum of 30 unique hashtags within any rolling 7-day period. Searching the same hashtag multiple times within that window does not reset the counter or add to the limit — only new unique hashtags count toward the 30-hashtag cap.

4. What permissions are required to access Instagram hashtag data via the API?

Your app needs approval for two things: the instagram_basic permission and the Instagram Public Content Access feature. Both must be granted through Meta's App Review process. Without these approvals, your app will not be able to query hashtag search endpoints or retrieve hashtagged media from public Instagram accounts.

5. Does the Instagram Hashtag Search API work for personal accounts?

No. The Instagram Hashtag Search API is only available to Instagram Business Accounts and Creator Accounts connected through the Meta (Facebook) developer platform. Personal Instagram accounts cannot initiate hashtag queries through the API, and the retrieved media will not include any personally identifiable information in the response.

6. What are the limitations of pulling Instagram photos by hashtag through the API?

Several restrictions apply. Hashtags used in Instagram Stories are not supported. Emoji-based hashtags cannot be queried. Hashtags flagged as sensitive or offensive return a generic error rather than results. You also cannot comment on hashtagged media discovered through the API, and responses are designed to exclude any personally identifiable user data.

7. What is the easiest way to pull Instagram photos by hashtag for influencer marketing or analytics?

Using a unified social data platform like Phyllo is the most efficient approach for teams that need reliable Instagram data at scale. Phyllo handles API authentication, access token management, and data retrieval — including content feeds, audience demographics, Instagram Stories, and Reels — through a single integration. This removes the complexity of building and maintaining a direct Instagram Graph API connection, making it well-suited for influencer marketing, creator analytics, and B2B use cases.


Adarsh Agarwal
Table of Content

Be the first to get insights and updates from Phyllo. Subscribe to our blog.

Ready to get started?

Sign up to get API keys or request us for a demo

/*