This page contains affiliate links. If you purchase through them we may earn a small commission at no extra cost to you. Learn more

Octopus Energy API: Automating Your Solar Setup

Updated 2026-04-038 min read
Smart energy meter showing electricity costs and solar savings

The Octopus Energy API is one of the most developer-friendly energy APIs in the UK. For solar and battery owners, it unlocks real-time pricing, consumption data, and tariff information that enables powerful automations.

What the Octopus API Provides

The API gives you access to:

Tariff Pricing

  • Agile import rates: Half-hourly prices for the next 24+ hours, published around 4pm daily
  • Agile export rates: What you'll earn for exporting in each half-hour
  • Flux rates: Fixed time-band pricing (cheap, standard, peak)
  • Historical rates: Past pricing for analysis and optimisation

Consumption Data

  • Half-hourly import: How much electricity you drew from the grid in each 30-minute slot
  • Half-hourly export: How much you sent back to the grid
  • Gas consumption: If you have a smart gas meter
  • Daily and monthly totals

Account Information

  • Tariff details: Which tariff you're on and its current rates
  • Meter details: MPAN, serial numbers
  • Account balance and payments

Accessing the API

API Key

Find your API key in the Octopus Energy dashboard: My Account > Developer Settings, or via the personal dashboard at octopus.energy/dashboard/developer.

Your API key is unique to your account and should be kept private. It provides read-only access to your data.

Base URL

All API requests go to: https://api.octopus.energy/v1/

Authentication

Use HTTP Basic Authentication with your API key as the username and an empty password.

Practical Uses for Solar Owners

1. Agile Price Monitoring

The Agile tariff changes price every 30 minutes. The API lets you:

  • See upcoming prices before they go live
  • Find the cheapest hours for battery charging
  • Identify expensive peak periods for battery discharge
  • Spot negative pricing events (free or paid-to-use electricity)

Prices for the next day are typically published between 4pm and 6pm. This gives you enough time to plan overnight charging and next-day strategy.

2. Export Rate Tracking

If you're on Agile export or SEG, knowing the export rate helps you decide whether to:

  • Export now (if the rate is high)
  • Store in your battery for later self-use (if import rates will be higher)
  • Hold battery charge for a future export window

3. Consumption Analysis

Half-hourly consumption data reveals:

  • Your base load (minimum consumption, typically overnight)
  • Peak usage times (morning routine, evening cooking)
  • How much solar offsets your daytime consumption
  • Whether your battery is reducing peak imports effectively

This data helps you optimise your energy behaviour and verify that your solar and battery system is working as expected.

Check Your Data Weekly at First

When you first install solar and/or a battery, check your half-hourly consumption data weekly via the API or Octopus dashboard. You'll spot patterns that suggest optimisation opportunities — like a base load that's higher than expected (something's always on that shouldn't be) or export during hours when you could be self-consuming.

Home Assistant Integration

The Octopus Energy integration for Home Assistant is the most common way UK solar owners interact with the API:

What It Provides

  • Current import/export rate: Real-time pricing sensor
  • Upcoming rates: Forecast of next 24–48 hours of pricing
  • Consumption sensors: Half-hourly import and export readings
  • Cost tracking: Running total of daily/weekly/monthly costs
  • Tariff information: Current tariff details

Key Entities

Smart meter displaying energy usage data
Smart meters enable time-of-use tariffs that reward flexible consumption

Once installed, the integration creates entities like:

  • sensor.octopus_energy_electricity_current_rate — current import price
  • sensor.octopus_energy_electricity_current_day_cost — today's cost so far
  • sensor.octopus_energy_electricity_export_current_rate — current export price

These entities feed into Predbat, dashboard displays, and automations.

Building Automations with Octopus Data

Cheap Rate Alerts

Send a notification when the import rate drops below a threshold:

Trigger: When sensor.octopus_current_rate drops below 10p/kWh Action: Send push notification: "Cheap electricity now! Rate: Xp/kWh until HH:MM"

This lets you manually shift loads to cheap periods while you're building confidence with automation.

Automatic Battery Charging

Trigger: When import rate is below 8p/kWh AND battery SOC is below 50% Action: Set battery to charge mode via GivTCP/Solis integration

This is basic compared to Predbat but works for simple setups.

Negative Pricing Response

On Octopus Agile, prices occasionally go negative:

Trigger: When import rate is negative (below 0p) Action: Set battery to charge, turn on immersion heater, send notification to run all appliances

You're being paid to use electricity — use as much as possible.

Peak Rate Battery Discharge

Trigger: When import rate exceeds 30p/kWh AND battery SOC is above 20% Action: Set battery to discharge mode

Sell stored electricity back during expensive periods.

Let Predbat Handle Complex Logic

Simple automations (charge when cheap, discharge when expensive) work but leave money on the table compared to Predbat's sophisticated planning. If you have the technical setup for Predbat, use it instead of building individual automations. Predbat considers all the variables together — individual automations can conflict or miss optimal strategies.

Solar panels generating electricity for the grid
Exporting surplus solar at peak times maximises your returns
GivEnergy All-in-One 5kW Hybrid Inverter

GivEnergy All-in-One 5kW Hybrid Inverter

£1,200
rated power kw

5

max pv input kw

7.5

mppt channels

2

battery voltage v

48V

View on Amazon

Affiliate link — we may earn a small commission at no extra cost to you

API Rate Limits and Best Practices

  • Octopus doesn't publish strict rate limits, but be reasonable (a few hundred calls per day is fine)
  • Cache responses where possible — pricing data doesn't change once published
  • Use the Home Assistant integration rather than direct API calls for most purposes
  • The API is occasionally slow during peak times (around 4pm when Agile prices are published)
GivEnergy All-in-One 9.5kWh Battery

GivEnergy All-in-One 9.5kWh Battery

£5,500
capacity kwh

9.5

usable capacity kwh

8.6

chemistry

LFP

cycles

6000

View on Amazon

Affiliate link — we may earn a small commission at no extra cost to you

Beyond the API: Octopus Mini

Octopus also provides the "Mini" in-home display and the Octopus app, which show much of the same data in a consumer-friendly format. For non-technical users, the app is sufficient. The API is for those who want to build automations or use tools like Predbat.

Combining Data Sources

The most powerful solar automations combine Octopus pricing with:

  • Solcast solar forecast — know what generation to expect
  • Inverter data — know battery state and current flows
  • Weather forecast — anticipate heating demand

Predbat combines all of these automatically. If you're building your own system, you'll need to integrate these data sources in Home Assistant and build logic that considers them together.

For the complete Home Assistant setup, see our Home Assistant guide. For automated battery scheduling, see our Predbat guide.

Share this article

Heatable
HeatableAward-winning service

The UK's fastest boiler installation service — from quote to fitted in as little as 24 hours. Award-winning, Trustpilot rated, with no pushy salesmen.

Get a boiler quote in 2 minutes

Affiliate link — we may earn a small commission at no extra cost to you

Stay informed

Get free solar updates direct to your inbox

Free updates on tariffs, grants & solar news. No spam, ever.

Related reading

What does this mean for YOUR home?

Design your perfect solar setup in under 3 minutes. Free, no sign-up required.

Build Your Solar System