PHPackages                             ampache/ampacheapi-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. ampache/ampacheapi-php

ActiveLibrary[API Development](/categories/api)

ampache/ampacheapi-php
======================

Ampache API PHP Library.

1.0.3(2y ago)483.2k↓49.4%5[1 issues](https://github.com/ampache/ampacheapi-php/issues)AGPL-3.0PHPPHP &gt;=5.4.0

Since Nov 18Pushed 4mo ago8 watchersCompare

[ Source](https://github.com/ampache/ampacheapi-php)[ Packagist](https://packagist.org/packages/ampache/ampacheapi-php)[ Docs](https://github.com/ampache/ampacheapi-php)[ RSS](/packages/ampache-ampacheapi-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (6)Used By (0)

ampacheapi-php
==============

[](#ampacheapi-php)

Ampache API PHP Library.

NEWS
----

[](#news)

Version 2 of this library is underway.

There are major changes to help support multiple purporses as well as both XML and JSON responses.

The library will now return a SimpleXMLElement or json\_encode string instead of the frankenstein.

This version of the library is supported from Ampache 6.2.0+

License
-------

[](#license)

Ampache API PHP Library is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3 (AGPLv3) as published by the Free Software Foundation.

Get Started
-----------

[](#get-started)

### Initialize

[](#initialize)

When creating an AmpacheApi object config is set using a config array.

- Required
    - username: string - Your API username
    - password: string - sha256 hashed API password
    - server: string - Server address, without http/https prefix
- Optional
    - debug: bool - Enable debug mode which will echo debug messages (default: false)
    - debug\_callback: string - server callback debugging function (default: null)
    - api\_secure: bool - Set to false to use http (default: true)
    - api\_format: string - Set API response version. 3, 4, 5, 6 (default: 6)
    - server\_version: int - Set API response format. xml, json (default: json)

So as an example; this is how the Ampache server would initialize the library.

```
// your own username and password are required to use Ampache server
$username = 'demo';
$password = 'demodemo';
$hash     = hash('sha256', $password);
$server   = 'develop.ampache.dev';

$config  = [
    'username' => $username,
    'password' => $password,
    'server' => $server,
    'debug' => true,
    'debug_callback' => null,
    'api_version' => 6,
    'api_format' => 'json',
];

$ampache = new AmpacheApi($config);
if ($ampache->state() != 'CONNECTED') {
    echo "Ampache API client failed to connect.\n";
    exit;
}
```

### Get server stats

[](#get-server-stats)

```
$stats = $ampache->info();
echo "Songs: " . $stats['songs'] . "\n";
echo "Albums: " . $stats['albums'] . "\n";
echo "Artists: " . $stats['artists'] . "\n";
echo "Playlists: " . $stats['playlists'] . "\n";
echo "Videos: " . $stats['videos'] . "\n";
```

### Get all artists

[](#get-all-artists)

```
$total = $stats['artists'];
$step  = 500; // Request per 500
$start = 0;

echo "Artists: \n";
while ($total > $start) {
    $artists = $ampache->send_command('artists', ['offset' => $start, 'limit' => $step]);
    foreach ($artists['artist'] as $artist) {
        echo "\t" . $artist['name'] . "\n";
    }
    $start = $start + $step;
}
```

Look in the [/examples](https://github.com/ampache/ampacheapi-php/tree/master/examples) folder for more.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance47

Moderate activity, may be stable

Popularity36

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~926 days

Total

4

Last Release

1054d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/99312cfd1b55c254916654c37378fe09d9a05c85f53ddb86397903a3efc17131?d=identicon)[Afterster](/maintainers/Afterster)

![](https://www.gravatar.com/avatar/3504744b32fba6af34a1641018a8a8cb8a28babade91da42f0de0904dcf1f141?d=identicon)[lachlan-00](/maintainers/lachlan-00)

---

Top Contributors

[![lachlan-00](https://avatars.githubusercontent.com/u/1305249?v=4)](https://github.com/lachlan-00 "lachlan-00 (48 commits)")[![Afterster](https://avatars.githubusercontent.com/u/2251352?v=4)](https://github.com/Afterster "Afterster (9 commits)")[![olaulau](https://avatars.githubusercontent.com/u/1771905?v=4)](https://github.com/olaulau "olaulau (2 commits)")[![gloony](https://avatars.githubusercontent.com/u/32897194?v=4)](https://github.com/gloony "gloony (1 commits)")

---

Tags

apilibraryampache

### Embed Badge

![Health badge](/badges/ampache-ampacheapi-php/health.svg)

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

###  Alternatives

[gorkalaucirica/hipchat-v2-api-client

Hipchat v2 API client

80223.4k6](/packages/gorkalaucirica-hipchat-v2-api-client)

PHPackages © 2026

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