PHPackages                             adyg/php-imgur-api-client - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. adyg/php-imgur-api-client

Abandoned → [j0k3r/php-imgur-api-client](/?search=j0k3r%2Fphp-imgur-api-client)Library[HTTP &amp; Networking](/categories/http)

adyg/php-imgur-api-client
=========================

Imgur API v3 client

4.0.0(4y ago)7811.0k123MITPHPPHP &gt;=7.4CI passing

Since Feb 18Pushed 3w ago2 watchersCompare

[ Source](https://github.com/Adyg/php-imgur-api-client)[ Packagist](https://packagist.org/packages/adyg/php-imgur-api-client)[ Docs](https://github.com/j0k3r/php-imgur-api-client)[ GitHub Sponsors](https://github.com/j0k3r)[ RSS](/packages/adyg-php-imgur-api-client/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (7)Versions (19)Used By (3)

PHP Imgur API Client
====================

[](#php-imgur-api-client)

[![CI](https://github.com/j0k3r/php-imgur-api-client/workflows/CI/badge.svg)](https://github.com/j0k3r/php-imgur-api-client/workflows/CI/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/3d004c0597a74e8208deb77e615f8a3c449570856a686c542221b063cfc16d63/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6a306b33722f7068702d696d6775722d6170692d636c69656e742f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/j0k3r/php-imgur-api-client?branch=master)[![Total Downloads](https://camo.githubusercontent.com/63534ae4414c6562af4556db7e3dddbe47c37bd0b710dd117bf0ae10501f0836/68747470733a2f2f706f7365722e707567782e6f72672f6a306b33722f7068702d696d6775722d6170692d636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/j0k3r/php-imgur-api-client)[![License](https://camo.githubusercontent.com/67a68f6fb72473af3055eecf6fc2a4144499b6bdffd340696b95b0aa42cfed05/68747470733a2f2f706f7365722e707567782e6f72672f6a306b33722f7068702d696d6775722d6170692d636c69656e742f6c6963656e7365)](https://packagist.org/packages/j0k3r/php-imgur-api-client)

Object Oriented PHP wrapper for the Imgur API.

Uses [Imgur API v3](https://api.imgur.com/).

Information
-----------

[](#information)

- Branch [1.x](https://github.com/j0k3r/php-imgur-api-client/tree/1.x) use Guzzle 3 (but is not maintained)
- Branch [2.x](https://github.com/j0k3r/php-imgur-api-client/tree/2.x) use Guzzle 5 (but is not maintained)
- Branch [3.x](https://github.com/j0k3r/php-imgur-api-client/tree/3.x) use Guzzle 6 and PHP &gt;= 5.6 (but is not maintained)
- Branch [master](https://github.com/j0k3r/php-imgur-api-client/tree/master) use Guzzle 7 and PHP &gt;= 8.2

Composer
--------

[](#composer)

Download Composer

```
$ curl -s http://getcomposer.org/installer | php
```

Add the library details to your composer.json

```
composer require j0k3r/php-imgur-api-client@^4.0
```

Install the dependency with

```
$ php composer.phar install
```

Basic usage
-----------

[](#basic-usage)

```
// This file is generated by Composer
require_once 'vendor/autoload.php';

$client = new \Imgur\Client();
$client->setOption('client_id', '[your app client id]');
$client->setOption('client_secret', '[your app client secret]');

if (isset($_SESSION['token'])) {
    $client->setAccessToken($_SESSION['token']);

    if ($client->checkAccessTokenExpired()) {
        $client->refreshToken();
    }
} elseif (isset($_GET['code'])) {
    $client->requestAccessToken($_GET['code']);
    $_SESSION['token'] = $client->getAccessToken();
} else {
    echo 'Click to authorize';
}
```

The API calls can be accessed via the `$client` object

```
$memes = $client->api('memegen')->defaultMemes();
```

Documentation
-------------

[](#documentation)

### Basic information

[](#basic-information)

This client follow the same tree as the [Imgur API](https://apidocs.imgur.com).

Here is the list of available *endpoints*: `account`, `album`, `comment`, `custom gallery`, `gallery`, `image`, `conversation`, `notification`, `memegen` &amp; `topic`.

You can access each endpoint using the `api()` method:

```
$client->api('album');
$client->api('comment');
$client->api('customGallery');
// etc ...
```

All available methods for each endpoints are in the folder [Api](lib/Imgur/Api). They mostly follow the description name in the Imgur doc. Here are few examples:

```
// for "Account Base" in account
$client->api('account')->base();
// for "Account Gallery Profile" in account
$client->api('account')->accountGalleryProfile();

// for "Filtered Out Gallery" in Custom Gallery
$client->api('customGallery')->filtered();

// for "Random Gallery Images" in gallery
$client->api('gallery')->randomGalleryImages();

// etc ...
```

### Uploading an image

[](#uploading-an-image)

If you want to **upload an image** you can use one of these solutions:

```
$pathToFile = '../path/to/file.jpg';
$imageData = [
    'image' => $pathToFile,
    'type'  => 'file',
];

$client->api('image')->upload($imageData);
```

or

```
$urlToFile = 'http://0.0.0.0/path/to/file.jpg';
$imageData = [
    'image' => $urlToFile,
    'type'  => 'url',
];

$client->api('image')->upload($imageData);
```

or

```
$pathToFile = '../path/to/file.jpg';
$imageData = [
    'image' => base64_encode(file_get_contents($pathToFile)),
    'type'  => 'base64',
];

$client->api('image')->upload($imageData);
```

### Pagination

[](#pagination)

For any API call that supports pagination and is not explicitly available via the method parameters, it can be achieved by using the `BasicPager` object and passing it as the second parameter in the `api()` call.

```
$pager = new \Imgur\Pager\BasicPager(1, 10);
$images = $client->api('account', $pager)->images();
```

Here is a real life example if you want to retrieve all your available images of an account:

```
$page = 1;
$pager = new \Imgur\Pager\BasicPager();
$res = $client->api('account', $pager)->images();

while (!empty($res)) {
    // var_dump(count($res));

    $pager->setPage($page++);

    $res = $client->api('account', $pager)->images();
}
```

This pager is really basic:

- You won't have information about how many pages are available
- If you request a non-existant page, you'll get an empty array

NOTE: `/gallery` endpoints do not support the `perPage` query string, and `/album/{id}/images` is not paged.

Please, read the [Imgur doc about it](https://api.imgur.com/#paging_results).

### Image id or Album id ?

[](#image-id-or-album-id-)

When you got an Imgur link it's almost impossible to be 100% sure if it's an image or an album. That's why we have an endpoint which might fix that by first checking an id as an image and if it's fail, test it as an album:

```
$data = $client->api('albumOrImage')->find($id);
```

License
-------

[](#license)

`php-imgur-api-client` is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance62

Regular maintenance activity

Popularity37

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 56.5% 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 ~167 days

Recently: every ~239 days

Total

18

Last Release

1627d ago

Major Versions

2.0.0 → 3.0.02016-11-04

2.0.1 → 3.0.12017-02-05

2.0.2 → 3.0.22019-04-11

2.x-dev → 3.0.42020-12-07

3.x-dev → 4.0.02021-12-03

PHP version history (4 changes)1.0.0PHP &gt;=5.3.2

3.0.0-beta.0PHP &gt;=5.5.0

2.0.2PHP &gt;=5.6.0

4.0.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/2cda822443b4541b53f896648c70caefb19ac4b44535cece653f6908b961dc46?d=identicon)[Adyg](/maintainers/Adyg)

---

Top Contributors

[![j0k3r](https://avatars.githubusercontent.com/u/62333?v=4)](https://github.com/j0k3r "j0k3r (108 commits)")[![Adyg](https://avatars.githubusercontent.com/u/287364?v=4)](https://github.com/Adyg "Adyg (72 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![harryqt](https://avatars.githubusercontent.com/u/18257605?v=4)](https://github.com/harryqt "harryqt (1 commits)")[![AlfredoRamos](https://avatars.githubusercontent.com/u/4165935?v=4)](https://github.com/AlfredoRamos "AlfredoRamos (1 commits)")[![mechpave](https://avatars.githubusercontent.com/u/5552556?v=4)](https://github.com/mechpave "mechpave (1 commits)")

---

Tags

clientguzzleimgurimgur-apiphpapiimgur

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/adyg-php-imgur-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/adyg-php-imgur-api-client/health.svg)](https://phpackages.com/packages/adyg-php-imgur-api-client)
```

###  Alternatives

[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.3M14](/packages/xeroapi-xero-php-oauth2)[cybercog/youtrack-rest-php

YouTrack REST API PHP Client.

37149.2k3](/packages/cybercog-youtrack-rest-php)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[ory/hydra-client

Documentation for all of Ory Hydra's APIs.

17435.9k](/packages/ory-hydra-client)[zenditplatform/zendit-php-sdk

PHP client for Zendit API

1204.3k](/packages/zenditplatform-zendit-php-sdk)[whatarmy/fedex-rest

New FedEx Rest API wrapper

2440.5k1](/packages/whatarmy-fedex-rest)

PHPackages © 2026

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