PHPackages                             moeplhausen/php-imgur - 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. moeplhausen/php-imgur

ActiveLibrary[API Development](/categories/api)

moeplhausen/php-imgur
=====================

Imgur API v3 client

3.0.1(9y ago)0261MITPHPPHP &gt;=5.5.0

Since Feb 18Pushed 9y agoCompare

[ Source](https://github.com/Moeplhausen/php-imgur-api-client)[ Packagist](https://packagist.org/packages/moeplhausen/php-imgur)[ Docs](https://github.com/j0k3r/php-imgur-api-client)[ RSS](/packages/moeplhausen-php-imgur/feed)WikiDiscussions 2.x Synced today

READMEChangelog (1)Dependencies (2)Versions (10)Used By (1)

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

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

[![Build Status](https://camo.githubusercontent.com/419839ef6dd8c588330be20b70617157afba979c162247a8ac2b16cb2f22bcd6/68747470733a2f2f7472617669732d63692e6f72672f6a306b33722f7068702d696d6775722d6170692d636c69656e742e7376673f6272616e63683d322e78)](https://travis-ci.org/j0k3r/php-imgur-api-client)[![Code Coverage](https://camo.githubusercontent.com/6ea4ff8e412c99d812fa18b368e6d68158fba4e3f772ac36abeec6b037206565/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a306b33722f7068702d696d6775722d6170692d636c69656e742f6261646765732f636f7665726167652e706e673f623d322e78)](https://scrutinizer-ci.com/g/j0k3r/php-imgur-api-client/?branch=2.x)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/76c0725568e10d3c9381bf8cd9a1382ae601aefd7616d7f090087b7d1069a133/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a306b33722f7068702d696d6775722d6170692d636c69656e742f6261646765732f7175616c6974792d73636f72652e706e673f623d322e78)](https://scrutinizer-ci.com/g/j0k3r/php-imgur-api-client/?branch=2.x)

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
- Branch [3.x](https://github.com/j0k3r/php-imgur-api-client/tree/3.x) use Guzzle 6

All actives branches required PHP &gt;= 5.5

Composer
--------

[](#composer)

Download Composer

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

Add the library details to your composer.json

```
"require": {
    "j0k3r/php-imgur-api-client": "^2.0.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://api.imgur.com/endpoints).

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

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 57.1% 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 ~120 days

Recently: every ~23 days

Total

10

Last Release

3433d ago

Major Versions

1.x-dev → 3.0.0-beta.02016-10-18

2.0.0 → 3.0.02016-11-04

2.x-dev → 3.0.12017-02-04

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

3.0.0-beta.0PHP &gt;=5.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/802346?v=4)[Moepl](/maintainers/Moeplhausen)[@Moeplhausen](https://github.com/Moeplhausen)

---

Top Contributors

[![Adyg](https://avatars.githubusercontent.com/u/287364?v=4)](https://github.com/Adyg "Adyg (72 commits)")[![j0k3r](https://avatars.githubusercontent.com/u/62333?v=4)](https://github.com/j0k3r "j0k3r (51 commits)")[![Moeplhausen](https://avatars.githubusercontent.com/u/802346?v=4)](https://github.com/Moeplhausen "Moeplhausen (2 commits)")[![mechpave](https://avatars.githubusercontent.com/u/5552556?v=4)](https://github.com/mechpave "mechpave (1 commits)")

---

Tags

apiimgur

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/moeplhausen-php-imgur/health.svg)

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.7k371.6k6](/packages/theodo-group-llphant)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

563.5M11](/packages/checkout-checkout-sdk-php)[clicksend/clicksend-php

301.6M11](/packages/clicksend-clicksend-php)

PHPackages © 2026

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