PHPackages                             j0k3r/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. j0k3r/php-imgur-api-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

j0k3r/php-imgur-api-client
==========================

Imgur API v3 client

4.0.3(2mo ago)7871.4k↑483.3%124MITPHPPHP &gt;=8.2CI passing

Since Feb 18Pushed 2mo ago2 watchersCompare

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

READMEChangelog (10)Dependencies (14)Versions (23)Used By (4)

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

64

—

FairBetter than 99% of packages

Maintenance87

Actively maintained with recent releases

Popularity44

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 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 ~222 days

Recently: every ~400 days

Total

21

Last Release

62d 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.0.5 → 4.0.02021-12-03

PHP version history (5 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

4.0.3PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/62333?v=4)[Jérémy Benoist](/maintainers/j0k3r)[@j0k3r](https://github.com/j0k3r)

---

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

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[jlevers/selling-partner-api

PHP client for Amazon's Selling Partner API

4335.4M2](/packages/jlevers-selling-partner-api)[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.6M18](/packages/xeroapi-xero-php-oauth2)[onesignal/onesignal-php-api

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

34199.5k2](/packages/onesignal-onesignal-php-api)[dreamfactory/df-core

DreamFactory(tm) Core Components

1652.0k38](/packages/dreamfactory-df-core)[zenditplatform/zendit-php-sdk

PHP client for Zendit API

1194.4k](/packages/zenditplatform-zendit-php-sdk)[huaweicloud/huaweicloud-sdk-php

Huawei Cloud SDK for PHP

1830.2k2](/packages/huaweicloud-huaweicloud-sdk-php)

PHPackages © 2026

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