PHPackages                             rogerthomas84/php-octopus-mini-api - 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. rogerthomas84/php-octopus-mini-api

ActiveLibrary[API Development](/categories/api)

rogerthomas84/php-octopus-mini-api
==================================

A working example of getting live consumption data from the Octopus API using PHP

1.0.3(1y ago)014mitPHPPHP &gt;=8.3CI failing

Since Jul 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rogerthomas84/php-octopus-mini-api)[ Packagist](https://packagist.org/packages/rogerthomas84/php-octopus-mini-api)[ Docs](https://github.com/rogerthomas84/php-octopus-mini-api)[ RSS](/packages/rogerthomas84-php-octopus-mini-api/feed)WikiDiscussions master Synced 2w ago

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

Octopus Mini API library
========================

[](#octopus-mini-api-library)

[![CI](https://github.com/rogerthomas84/php-octopus-mini-api/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/rogerthomas84/php-octopus-mini-api/actions/workflows/ci.yml/badge.svg?branch=master)

### Description...

[](#description)

This is a simple library, with a basic implementation of the Octopus API, as well as a small part of their GraphQL API. It's original purpose was primarily to serve as a documentation of how to retrieve the live consumption data from the Octopus Energy GraphQL API, but has since been expanded to include some other basic functionality, such as retrieval of half-hourly consumption data, as well as account information.

In order to retrieve the live consumption data, you must have an Octopus Mini device, and (obviously) you need to have an account with Octopus Energy. If you have an Octopus account, but don't have a Mini device, you can request a free one from Octopus Energy [here](https://octopus.typeform.com/to/B5ifg5rQ).

Much of this library has been written using the documentation available from Octopus:

-
-
-
-

### Usage...

[](#usage)

```
composer require rogerthomas84/php-octopus-mini-api

```

```
$api = \Rt\OctopusAPI\OctopusApiSingleton::getInstance();
$apiInstance = $api->setEmail(
    getenv('OCTOPUS_EMAIL')
)->setPassword(
    getenv('OCTOPUS_PASSWORD')
)->setAccountNumber(
    getenv('OCTOPUS_ACCOUNT_NUMBER')
)->setApiKey(
    getenv('OCTOPUS_API_KEY')
)->setMpan(
    getenv('OCTOPUS_MPAN')
)->setSerialNumber(
    getenv('OCTOPUS_SERIAL_NUMBER')
);

$graphQl = $apiInstance->getOctopusGraphQL();

// $myToken = $graphQl->getToken();
// $meterDeviceId = $graphQl->getMeterDeviceId();
$consumption = $graphQl->getLiveConsumption();
// or you can pass the meterDeviceId directly:
// $consumption = $graphQl->getLiveConsumption($meterDeviceId);

echo 'Current consumption is ' . $consumption . 'W\n';

$myAccount = $apiInstance->getAccount();
echo 'You have ' . count($myAccount->getProperties()) . ' properties on your account\n';

$myProperty = $myAccount->getProperties()[0];
echo 'The first property on your account is ' . $myProperty->getAddressLine1() . "\n";

$myMeter = $myProperty->getElectricityMeterPoints()[0];
echo 'The first electricity meter point on your property is ' . $myMeter->getMpan() . "\n";

$myAgreement = $myMeter->getAgreements()[0];
$myTariffCode = $myAgreement->getTariffCode();
echo 'My tariff code is ' . $myAgreement->getTariffCode() . "\n";

$dateFrom = DateTime::createFromFormat('Y-m-d', '2021-01-01');
$dateTo = DateTime::createFromFormat('Y-m-d', '2021-01-02');

$consumptionData = $apiInstance->getElectricityService()->getHalfHourReadings(
    $dateFrom,
    $dateTo,
    25000, // limit per page
    '-period' // or 'period', used for sorting
);

$standingCharges = $apiInstance->getElectricityService()->getStandingCharges(
    $myTariffCode,
    $dateFrom,
    $dateTo,
    25000, // limit per page
);

$unitRates = $apiInstance->getElectricityService()->getStandardUnitRates(
    $myTariffCode,
    $dateFrom,
    $dateTo,
    25000, // limit per page
);
```

### Testing...

[](#testing)

To test this, you'll need to set the following environment variables:

- `OCTOPUS_EMAIL`
- `OCTOPUS_PASSWORD`
- `OCTOPUS_ACCOUNT_NUMBER`
- `OCTOPUS_API_KEY`
- `OCTOPUS_MPAN`
- `OCTOPUS_SERIAL_NUMBER`

Then run the following commands:

```
composer install
./vendor/bin/phpunit

```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~55 days

Total

4

Last Release

607d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5de4b9a90eadf6b595e1b5efc802683f2358da5661c616820b90c922f8aa8e05?d=identicon)[rogerthomas84](/maintainers/rogerthomas84)

---

Top Contributors

[![rogerthomas84](https://avatars.githubusercontent.com/u/350232?v=4)](https://github.com/rogerthomas84 "rogerthomas84 (6 commits)")

---

Tags

phplibraryoctopusapi

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rogerthomas84-php-octopus-mini-api/health.svg)

```
[![Health](https://phpackages.com/badges/rogerthomas84-php-octopus-mini-api/health.svg)](https://phpackages.com/packages/rogerthomas84-php-octopus-mini-api)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

563.6M16](/packages/checkout-checkout-sdk-php)[resend/resend-php

Resend PHP library.

608.3M53](/packages/resend-resend-php)[files.com/files-php-sdk

Files.com PHP SDK

2482.9k](/packages/filescom-files-php-sdk)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

793.9k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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