PHPackages                             bubalubs/craft-instagram-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. bubalubs/craft-instagram-api

ActiveCraft-plugin[API Development](/categories/api)

bubalubs/craft-instagram-api
============================

Instagram API Integration for Craft CMS, allowing you to fetch media from Instagram and display it on your website.

0.2(2y ago)532[5 issues](https://github.com/Bubalubsio/craft-instagram-api/issues)proprietaryPHPPHP &gt;=8.2

Since May 1Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Bubalubsio/craft-instagram-api)[ Packagist](https://packagist.org/packages/bubalubs/craft-instagram-api)[ RSS](/packages/bubalubs-craft-instagram-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Instagram Plugin - Craft CMS
============================

[](#instagram-plugin---craft-cms)

Instagram Integration for Craft CMS, allowing you to fetch media and profile from Instagram and display it on your website via the Instagram API.

Features
--------

[](#features)

- Craft 5 Support!
- No dependencies on third-party libraries
- Authenticate via OAuth 2
- Fetch Instagram Media and Profile Data
- Twig, Javascript and PHP API
- Full caching support with preheating/clearing controls
- Cron job support for refreshing access tokens
- Manual token refreshing from the control panel or CLI

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 5.0.0 or later, and PHP 8.2 or later.

Installation
------------

[](#installation)

You can install this plugin from the Plugin Store or with Composer.

#### From the Plugin Store

[](#from-the-plugin-store)

Go to the Plugin Store in your project’s Control Panel and search for "Instagram API". Then press "Install".

#### With Composer

[](#with-composer)

Open your terminal and run the following commands:

```
# go to the project directory
cd /path/to/my-project.test

# tell Composer to load the plugin
composer require bubalubs/craft-instagram-api

# tell Craft to install the plugin
./craft plugin/install craft-instagram-api
```

Setup
-----

[](#setup)

### Step 1

[](#step-1)

First you need to create an Instagram App. You can do this by visiting the Facebook Developers page. When creating the app select use case `Other`, then `Comsumer`. and then you will be able to Set Up the Instagram Basic Display.

Add your instagram account to `App Roles -> Roles` on your Instagram App settings.

Note: You can find your App ID, App Secret and Valid OAuth Redirect URIs at: `Facebook Developers -> App Settings -> Products -> Instagram Basic Display -> Basic Display`

### Step 2

[](#step-2)

Add the URI from the from Plugin's Settings to the Valid OAuth Redirect URIs field on your Instagram App settings.

Note: If you are in a development environment, remember to additionally add your live domain to the Valid OAuth Redirect URIs field.

### Step 3

[](#step-3)

Fill in the Plugin Settings your Instagram App ID and Instagram App Secret.

### Step 4

[](#step-4)

After saving your Instagram App ID and Secret, you need to authenticate with Instagram to get an access token. Click the button in the Plugin Settings start the authorization flow with Instagram.

Usage
-----

[](#usage)

### Javascript API Examples

[](#javascript-api-examples)

#### Get Instagram Media

[](#get-instagram-media)

Endpoint: `/actions/instagram-api/api/media`

```
fetch('/actions/instagram-api/api/media')
  .then(response => response.json())
  .then(data => {
      console.log(data);
  });

```

#### Get Instagram Profile

[](#get-instagram-profile)

Endpoint: `/actions/instagram-api/api/profile`

```
fetch('/actions/instagram-api/api/profile')
  .then(response => response.json())
  .then(data => {
      console.log(data);
  });

```

### Twig Examples

[](#twig-examples)

#### Loop through Instagram Media

[](#loop-through-instagram-media)

```
{% set instagramMedia = craft.instagram.getMedia() %}

{% if instagramMedia|length %}

        {% for media in instagramMedia %}

        {% endfor %}

{% endif %}

```

#### Get Profile Data

[](#get-profile-data)

```
{% set instagramProfile = craft.instagram.getProfile() %}

{% if instagramProfile %}
  Instagram Profile

      ID: {{ instagramProfile.id }}
      Username: {{ instagramProfile.username }}
      Account Type: {{ instagramProfile.account_type }}
      Media Count: {{ instagramProfile.media_count }}

{% endif %}

```

### PHP Examples

[](#php-examples)

#### Loop through Instagram Media and save locally

[](#loop-through-instagram-media-and-save-locally)

```
use bubalubs\instagramapi\InstagramAPI;

// ...

$instagramMedia = InstagramAPI::getInstance()->instagram->getMedia();

foreach ($instagramMedia as $media) {
    $mediaUrl = $media['media_url'];
    $file = file_get_contents($mediaUrl);

    // Strip query string from filename
    $newFilename = pathinfo(explode('?', $mediaUrl)[0], PATHINFO_BASENAME);

    // Check if directory exists
    if (!file_exists(Craft::$app->path->getStoragePath() . '/instagram')) {
        mkdir(Craft::$app->path->getStoragePath() . '/instagram', 0775, true);
    }

    // Save file locally
    file_put_contents(Craft::$app->path->getStoragePath() . '/instagram/' . $newFilename, $file);
}

```

#### Get Profile Data

[](#get-profile-data-1)

```
use bubalubs\instagramapi\InstagramAPI;

// ...

$instagramProfile = InstagramAPI::getInstance()->instagram->getProfile();

```

CLI Commands
------------

[](#cli-commands)

### Refresh Access Token

[](#refresh-access-token)

```
./craft instagram-api/refresh-token

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

2

Last Release

731d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b617997148c05d304a19b92af8043b61ff88f5659bf1ef725008317b1f5d1537?d=identicon)[Bubalubs](/maintainers/Bubalubs)

---

Top Contributors

[![Bubalubs](https://avatars.githubusercontent.com/u/4392150?v=4)](https://github.com/Bubalubs "Bubalubs (47 commits)")

---

Tags

craftcmscraftcms-plugincraftcms5instagraminstagram-api

### Embed Badge

![Health badge](/badges/bubalubs-craft-instagram-api/health.svg)

```
[![Health](https://phpackages.com/badges/bubalubs-craft-instagram-api/health.svg)](https://phpackages.com/packages/bubalubs-craft-instagram-api)
```

###  Alternatives

[craftcms/element-api

Create a JSON API for your elements in Craft

503701.3k8](/packages/craftcms-element-api)[markhuot/craftql

A GraphQL implementation for Craft

31844.7k](/packages/markhuot-craftql)[wrav/oembed

A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles.

36205.0k3](/packages/wrav-oembed)[imarc/craft-googlecustomsearch

A Craft plugin for integrating with Google's Custom Search (and Google's Site Search.)

2312.3k](/packages/imarc-craft-googlecustomsearch)[scaramangagency/craftagram

Grab Instagram content through the Instagram API

1426.0k](/packages/scaramangagency-craftagram)[dukt/twitter

Tweet field, search widget, embeds, and authenticated Twitter API requests.

1326.7k](/packages/dukt-twitter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
