PHPackages                             alexok/instagram-sdk-php - 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. alexok/instagram-sdk-php

ActiveLibrary[API Development](/categories/api)

alexok/instagram-sdk-php
========================

This is an unofficial SDK for the Instagram Private API in PHP

1.0.4(9y ago)251MITPHPPHP &gt;=5.3.0

Since May 10Pushed 8y ago1 watchersCompare

[ Source](https://github.com/alexok/Instagram-SDK-PHP)[ Packagist](https://packagist.org/packages/alexok/instagram-sdk-php)[ RSS](/packages/alexok-instagram-sdk-php/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (9)Used By (0)

Instagram-SDK-PHP
-----------------

[](#instagram-sdk-php)

[![Latest Stable Version](https://camo.githubusercontent.com/5ef8140362043fd4d30b107aba9f7a067475ddbe3f2d024310b15ec54640a5b3/68747470733a2f2f706f7365722e707567782e6f72672f6c69616d636f74746c652f696e7374616772616d2d73646b2d7068702f76657273696f6e)](https://packagist.org/packages/liamcottle/instagram-sdk-php)[![Latest Unstable Version](https://camo.githubusercontent.com/e262495fe528c652d6a507942293c9cc829dd1ec2461264f4d4b9f86cfdfab51/68747470733a2f2f706f7365722e707567782e6f72672f6c69616d636f74746c652f696e7374616772616d2d73646b2d7068702f762f756e737461626c65)](//packagist.org/packages/liamcottle/instagram-sdk-php)[![Total Downloads](https://camo.githubusercontent.com/3c2d3f322eb358ba4aed80ee4214d7a6de2865daa68260a831418b666715e21a/68747470733a2f2f706f7365722e707567782e6f72672f6c69616d636f74746c652f696e7374616772616d2d73646b2d7068702f646f776e6c6f616473)](https://packagist.org/packages/liamcottle/instagram-sdk-php)[![Daily Downloads](https://camo.githubusercontent.com/5b114f44e37b106747e5c88931ae321edc686cd0fd9768b079b89a142514880d/68747470733a2f2f706f7365722e707567782e6f72672f6c69616d636f74746c652f696e7374616772616d2d73646b2d7068702f642f6461696c79)](https://packagist.org/packages/liamcottle/instagram-sdk-php)

This is an unofficial SDK for the Instagram Private API in PHP

Motivation
----------

[](#motivation)

I decided to build this because most libraries for the Instagram Private API I have come across aren't OOP based and are difficult to use.

Donations
---------

[](#donations)

If you like this project, please consider donating towards my coffee addiction fund, so I can continue to push commits!

- [![Paypal](https://raw.githubusercontent.com/reek/anti-adblock-killer/gh-pages/images/paypal.png)](https://raw.githubusercontent.com/reek/anti-adblock-killer/gh-pages/images/paypal.png) Paypal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=JMMKQZYBM2SA8)
- [![btc](https://camo.githubusercontent.com/4bc31b03fc4026aa2f14e09c25c09b81e06d5e71/687474703a2f2f7777772e6d6f6e747265616c626974636f696e2e636f6d2f696d672f66617669636f6e2e69636f)](https://camo.githubusercontent.com/4bc31b03fc4026aa2f14e09c25c09b81e06d5e71/687474703a2f2f7777772e6d6f6e747265616c626974636f696e2e636f6d2f696d672f66617669636f6e2e69636f) Bitcoin: 1814x9kioBxPDBCQx8oaty7e6Z3DAosucd

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

[](#installation)

### Composer

[](#composer)

```
composer require liamcottle/instagram-sdk-php
```

```
require("../vendor/autoload.php");
$instagram = new \Instagram\Instagram();
```

If you want to test code that is in the master branch, which hasn't been pushed as a release, you can use `dev-master`.

```
composer require liamcottle/instagram-sdk-php dev-master
```

### Don't have Composer?

[](#dont-have-composer)

What?! Grab it here:

Examples
--------

[](#examples)

Examples can be seen in the [examples](./examples) folder.

Usage
-----

[](#usage)

### Login

[](#login)

Read: [Session Management](#session-management), to avoid calling `login` in each script.

```
$instagram->login("username", "password");
```

### Timeline Feed

[](#timeline-feed)

- `$maxId`:`string` (Optional) Used for Pagination

```
$instagram->getTimelineFeed($maxId);
```

### User Feed

[](#user-feed)

- `$userId`:`string|User` User or User Id to get Feed of
- `$maxId`:`string` (Optional) Used for Pagination

```
$instagram->getUserFeed($userId, $maxId);
```

### My User Feed

[](#my-user-feed)

- `$maxId`:`string` (Optional) Used for Pagination

```
$instagram->getMyUserFeed($maxId);
```

### Liked Feed

[](#liked-feed)

- `$maxId`:`string` (Optional) Used for Pagination

```
$instagram->getLikedFeed($maxId);
```

### Tag Feed

[](#tag-feed)

- `$tag`:`string` Tag
- `$maxId`:`string` (Optional) Used for Pagination

```
$instagram->getTagFeed($tag, $maxId);
```

### Location Feed

[](#location-feed)

- `$locationId`:`string|Location` Location or Location Id to get Feed of
- `$maxId`:`string` (Optional) Used for Pagination

```
$instagram->getLocationFeed($locationId, $maxId);
```

### User Tags Feed

[](#user-tags-feed)

- `$userId`:`string|User` User of User Id to get Tags Feed of
- `$maxId`:`string` (Optional) Used for Pagination

```
$instagram->getUserTagsFeed($userId, $maxId);
```

### Like Media

[](#like-media)

- `$mediaId`:`string|FeedItem` FeedItem or FeedItem Id to Like

```
$instagram->likeMedia($mediaId);
```

### Unlike Media

[](#unlike-media)

- `$mediaId`:`string|FeedItem` FeedItem or FeedItem Id to Unlike

```
$instagram->unlikeMedia($mediaId);
```

### Delete Media

[](#delete-media)

- `$mediaId`:`string|FeedItem` FeedItem or FeedItem Id to Delete
- `$mediaType`:`int` Media Type (Constants available in `DeleteMediaRequest` class)

```
$instagram->deleteMedia($mediaId, $mediaType);
```

### Comment on Media

[](#comment-on-media)

- `$mediaId`:`string|FeedItem` FeedItem or FeedItem Id to Comment on
- `$comment`:`string` Comment

```
$instagram->commentOnMedia($mediaId, $comment);
```

### Get Media Comments

[](#get-media-comments)

- `$mediaId`:`string|FeedItem` FeedItem or FeedItem Id of Media to get Comments from
- `$maxId`:`string` (Optional) Used for Pagination

```
$instagram->getMediaComments($mediaId, $maxId);
```

### Delete Media Comments

[](#delete-media-comments)

- `$mediaId`:`string|FeedItem` FeedItem or FeedItem Id to Delete Comments from
- `$commentIds`:`array` Comment Ids to Delete

```
$instagram->deleteCommentsFromMedia($mediaId, $commentIds);
```

### User Info

[](#user-info)

- `$userId`:`string|User` User or User Id to get Info of

```
$instagram->getUserInfo($userId);
```

### User Followers

[](#user-followers)

- `$userId`:`string|User` User or User Id to get Followers of
- `$maxId`:`string` (Optional) Used for Pagination

```
$instagram->getUserFollowers($userId, $maxId);
```

### User Following

[](#user-following)

- `$userId`:`string|User` User or User Id to get Following of
- `$maxId`:`string` (Optional) Used for Pagination

```
$instagram->getUserFollowing($userId, $maxId);
```

### GeoMedia

[](#geomedia)

- `$userId`:`string|User` User or User Id to get GeoMedia of

```
$instagram->getUserMap($userId);
```

### Media Info

[](#media-info)

- `$mediaId`:`string|FeedItem` FeedItem or FeedItem Id to get Info of

```
$instagram->getMediaInfo($mediaId);
```

### Current User Account

[](#current-user-account)

```
$instagram->getCurrentUserAccount();
```

### Edit User Profile

[](#edit-user-profile)

- `$firstname`:`string` First Name
- `$email`:`string` Email
- `$phoneNumber`:`string` Phone Number
- `$gender`:`int` Gender (Constants available in `User` class)
- `$biography`:`string`: Biography
- `$externalUrl`:`string` External Url

```
$instagram->editUserProfile($firstname, $email, $phoneNumber, $gender, $biography, $externalUrl);
```

### Set Account Public

[](#set-account-public)

```
$instagram->setAccountPublic();
```

### Set Account Private

[](#set-account-private)

```
$instagram->setAccountPrivate();
```

### Show Friendship

[](#show-friendship)

- `$userId`:`string|User` User or User Id to show Friendship between

```
$instagram->showFriendship($userId);
```

### Follow User

[](#follow-user)

- `$userId`:`string|User` User or User Id to Follow

```
$instagram->followUser($userId);
```

### Unfollow User

[](#unfollow-user)

- `$userId`:`string|User` User or User Id to Unfollow

```
$instagram->unfollowUser($userId);
```

### Block User

[](#block-user)

- `$userId`:`string|User` User or User Id to Block

```
$instagram->blockUser($userId);
```

### Unblock User

[](#unblock-user)

- `$userId`:`string|User` User or User Id to Unblock

```
$instagram->unblockUser($userId);
```

### Search Tags

[](#search-tags)

- `$query`:`string` Tag to Search for

```
$instagram->searchTags($query);
```

### Search Users

[](#search-users)

- `$query`:`string` User to Search for

```
$instagram->searchUsers($query);
```

### Search Places (Facebook)

[](#search-places-facebook)

- `$query`:`string` Place to Search for

```
$instagram->searchFacebookPlaces($query);
```

- `$latitude`:`string` Latitude
- `$longitude`:`string` Longitude

```
$instagram->searchFacebookPlacesByLocation($latitude, $longitude);
```

### Change Profile Picture

[](#change-profile-picture)

- `$path`:`string` File path of Profile Picture to Upload

```
$instagram->changeProfilePicture($path);
```

### Remove Profile Picture

[](#remove-profile-picture)

```
$instagram->removeProfilePicture();
```

### Post Photo

[](#post-photo)

- `$path`:`string` File path of Photo to Post
- `$caption`:`string` Caption for this Photo

```
$instagram->postPhoto($path, $caption);
```

### Edit Media

[](#edit-media)

- `$mediaId`:`string|FeedItem` FeedItem or FeedItem Id to Edit
- `$caption`:`string` Caption for this Media

```
$instagram->editMedia($mediaId, $caption);
```

### Get User by Username

[](#get-user-by-username)

- `$username`:`string` Username to find User by

```
$instagram->getUserByUsername($username);
```

### Logout

[](#logout)

```
$instagram->logout();
```

Session Management
------------------

[](#session-management)

To avoid logging in each time, you can use the `saveSession` and `initFromSavedSession` methods.

Script 1:

```
//Login
$instagram->login("username", "password");

//Serialize the Session into a JSON string
$savedSession = $instagram->saveSession();

//Store $savedSession in Database, or Cookie etc
```

Script 2:

```
//Load $savedSession from Database or Cookie etc
$savedSession = ...;

//Init from Saved Session
$instagram->initFromSavedSession($savedSession);

//Session is Restored, do something!
$instagram-> ...;
```

Extras
------

[](#extras)

### Pagination

[](#pagination)

Some Instagram endpoints return paginated data.

To access the next page of data, you will need to get the next maximum ID from the response object and pass it into the same method as the `nextMaxId` parameter.

**Example:**

```
//Get TimelineFeed
$timelineFeed = $instagram->getTimelineFeed();

//This will be null if there are no more pages.
$nextMaxId = $timelineFeed->getNextMaxId();

//We have another page of Items
if($nextMaxId != null){
	//Get the next page.
	$timelineFeed = $instagram->getTimelineFeed($nextMaxId);
}
```

### Proxy

[](#proxy)

Use a Proxy between your Server and the Instagram API

```
$instagram->setProxy("127.0.0.1:8888");
```

Optional Username/Password Authentication

```
$instagram->setProxy("127.0.0.1:8888", "proxyUsername", "proxyPassword");
```

Enable or Disable Peer Verification, for testing with Charles Proxy etc.

```
$instagram->setVerifyPeer(false);
```

TODO
----

[](#todo)

- Inbox
- Direct Share
- Recent Activity
- Register new Accounts
- Upload and Post Videos

Contributing
------------

[](#contributing)

If you would like to contribute to this project, please feel free to submit a pull request.

Before you do, take a look at the issues to see if the functionality you want to contribute to is already in development.

License
-------

[](#license)

MIT

Legal
-----

[](#legal)

The name "Instagram" is a copyright of Instagram, Inc.

This project is in no way affiliated with, authorized, maintained, sponsored or endorsed by Instagram, Inc or any of its affiliates or subsidiaries.

I, the project owner and creator, am not responsible for any legalities that may arise in the use of this project. Use at your own risk.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 56.8% 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 ~20 days

Total

5

Last Release

3569d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/02e24c18d4cc47893991b8e5e06a9bbc2fc764a783b0cd7cfaf1c0e04e69139f?d=identicon)[alexok](/maintainers/alexok)

---

Top Contributors

[![alexok](https://avatars.githubusercontent.com/u/1074728?v=4)](https://github.com/alexok "alexok (25 commits)")[![liamcottle](https://avatars.githubusercontent.com/u/3173581?v=4)](https://github.com/liamcottle "liamcottle (19 commits)")

---

Tags

phpapisdkinstagramprivate

### Embed Badge

![Health badge](/badges/alexok-instagram-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/alexok-instagram-sdk-php/health.svg)](https://phpackages.com/packages/alexok-instagram-sdk-php)
```

###  Alternatives

[liamcottle/instagram-sdk-php

This is an unofficial SDK for the Instagram Private API in PHP

1308.4k](/packages/liamcottle-instagram-sdk-php)[pgrimaud/instagram-user-feed

This is a scraper to easily fetch any feed and interact with Instagram (like, follow, etc.) without OAuth for PHP.

940657.1k5](/packages/pgrimaud-instagram-user-feed)[jstolpe/instagram-graph-api-php-sdk

Instagram Graph API PHP SDK

13998.4k2](/packages/jstolpe-instagram-graph-api-php-sdk)[manamine/php-eos-rpc-sdk

PHP SDK for the EOS RPC API

207.5k](/packages/manamine-php-eos-rpc-sdk)

PHPackages © 2026

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