Tesla Energy History API

Historical energy production, consumption, and battery flow

OpenAPI Specification

tesla-energy-history-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Tesla Fleet Energy Backup History API
  description: 'The energy_sites surface of the Tesla Fleet API. Lets OAuth-authorized partners and owners read

    Powerwall, Solar, and Megapack site state — site info, live status, calendar history, programs —

    and write backup reserve, operation mode (self_consumption, backup, autonomous), storm mode,

    time-of-use settings, and off-grid vehicle charging reserve.


    Authentication uses Tesla Fleet API OAuth 2.0 with the energy_device_data (read) and

    energy_cmds (write) scopes. Third-party applications must register a partner account on the

    Tesla Developer Portal and pair a virtual key with the owner''s account.

    '
  version: 1.0.0
  contact:
    name: Tesla Developer Support
    url: https://developer.tesla.com/docs/fleet-api/support/contact
  license:
    name: Tesla Developer Terms
    url: https://developer.tesla.com/teslaplatform/developerterms
servers:
- url: https://fleet-api.prd.na.vn.cloud.tesla.com/api/1
  description: North America Production
- url: https://fleet-api.prd.eu.vn.cloud.tesla.com/api/1
  description: Europe / Middle East / Africa Production
security:
- BearerAuth:
  - energy_device_data
  - energy_cmds
tags:
- name: History
  description: Historical energy production, consumption, and battery flow
paths:
  /energy_sites/{site_id}/calendar_history:
    get:
      summary: Tesla Get Energy Site Calendar History
      description: Returns time-series energy data — production, consumption, grid import/export, battery charge/discharge — aggregated by day, week, month, or year. Supports kind=energy, power, self_consumption, savings, and time_of_use.
      operationId: getEnergySiteCalendarHistory
      tags:
      - History
      parameters:
      - $ref: '#/components/parameters/SiteId'
      - name: kind
        in: query
        required: true
        description: Type of history to retrieve.
        schema:
          type: string
          enum:
          - energy
          - power
          - self_consumption
          - savings
          - time_of_use
      - name: period
        in: query
        required: false
        description: Aggregation period.
        schema:
          type: string
          enum:
          - day
          - week
          - month
          - year
          - lifetime
      - name: end_date
        in: query
        required: false
        description: ISO-8601 end of the window.
        schema:
          type: string
          format: date-time
      - name: time_zone
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CalendarHistoryResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    CalendarHistoryResponse:
      type: object
      properties:
        response:
          type: object
          properties:
            serial_number:
              type: string
            period:
              type: string
            installation_time_zone:
              type: string
            time_series:
              type: array
              items:
                $ref: '#/components/schemas/CalendarHistoryBucket'
    Error:
      type: object
      properties:
        error:
          type: string
        error_description:
          type: string
    CalendarHistoryBucket:
      type: object
      properties:
        timestamp:
          type: string
          format: date-time
        solar_energy_exported:
          type: number
        generator_energy_exported:
          type: number
        grid_energy_imported:
          type: number
        grid_services_energy_imported:
          type: number
        grid_services_energy_exported:
          type: number
        grid_energy_exported_from_solar:
          type: number
        grid_energy_exported_from_generator:
          type: number
        grid_energy_exported_from_battery:
          type: number
        battery_energy_exported:
          type: number
        battery_energy_imported_from_grid:
          type: number
        battery_energy_imported_from_solar:
          type: number
        battery_energy_imported_from_generator:
          type: number
        consumer_energy_imported_from_grid:
          type: number
        consumer_energy_imported_from_solar:
          type: number
        consumer_energy_imported_from_battery:
          type: number
        consumer_energy_imported_from_generator:
          type: number
  responses:
    Unauthorized:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  parameters:
    SiteId:
      name: site_id
      in: path
      required: true
      description: The energy_site_id returned by /products.
      schema:
        type: string
  securitySchemes:
    BearerAuth:
      type: oauth2
      description: Tesla Fleet API OAuth 2.0 with PKCE. Scopes energy_device_data (read) and energy_cmds (write) required for the energy_sites endpoints.
      flows:
        authorizationCode:
          authorizationUrl: https://auth.tesla.com/oauth2/v3/authorize
          tokenUrl: https://auth.tesla.com/oauth2/v3/token
          scopes:
            energy_device_data: Read energy site data
            energy_cmds: Send commands to energy sites
            offline_access: Refresh tokens