> ## Documentation Index
> Fetch the complete documentation index at: https://developer.energy-hub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Consumption for user

> Returns a paginated list of consumption of a tariff in hourly periods for the user.The list is sorted in the way that the latest records are shown first.



## OpenAPI

````yaml get /v1.0.0/users/{userId}/tariffs/{tariffId}/consumption
openapi: 3.0.1
info:
  description: A service used for smart energy players
  title: smart-energy-service
  version: 1.0.0
servers:
  - description: Generated server url
    url: https://api.energy-hub.io
security: []
paths:
  /v1.0.0/users/{userId}/tariffs/{tariffId}/consumption:
    get:
      tags:
        - User Tariff Controller
      summary: Consumption for user
      description: >-
        Returns a paginated list of consumption of a tariff in hourly periods
        for the user.The list is sorted in the way that the latest records are
        shown first.
      operationId: getConsumptionByUserAndTariff
      parameters:
        - schema:
            type: string
          in: path
          name: userId
          description: User ID
          required: true
        - schema:
            format: uuid
            type: string
          in: path
          name: tariffId
          description: Tariff ID
          required: true
        - schema:
            format: int32
            type: integer
            minimum: 0
          in: query
          name: page
          description: Zero-based page index (0..N)
          required: false
          example: 0
        - schema:
            format: int32
            maximum: 5000
            type: integer
            minimum: 1
          in: query
          name: size
          description: >-
            The size of the page to be returned. Default value is 100. Maximum
            value is 5000.
          required: false
          example: 100
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PageResponseConsumptionResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorMessageDto'
              examples:
                BAD_REQUEST:
                  $ref: '#/components/examples/BAD_REQUEST'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                UNAUTHORIZED:
                  $ref: '#/components/examples/UNAUTHORIZED'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                TARIFF_NOT_FOUND:
                  $ref: '#/components/examples/TARIFF_NOT_FOUND'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                VENDOR_ACCOUNT_IS_DISCONNECTED:
                  $ref: '#/components/examples/VENDOR_ACCOUNT_IS_DISCONNECTED'
                VENDOR_COMMUNICATION_ERROR:
                  $ref: '#/components/examples/VENDOR_COMMUNICATION_ERROR'
                VENDOR_AUTHENTICATION_ERROR:
                  $ref: '#/components/examples/VENDOR_AUTHENTICATION_ERROR'
                VENDOR_CONNECTION_ERROR:
                  $ref: '#/components/examples/VENDOR_CONNECTION_ERROR'
      security:
        - API_Key: []
components:
  schemas:
    PageResponseConsumptionResponse:
      type: object
      required:
        - content
        - totalElements
        - totalPages
      properties:
        totalPages:
          format: int64
          description: Total number of pages.
          type: integer
          example: 1
        content:
          description: >-
            Elements in the page. If there is no elements the list will be
            empty.
          type: array
          items:
            $ref: '#/components/schemas/ConsumptionResponse'
        totalElements:
          format: int64
          description: Total number of elements.
          type: integer
          example: 1
    ValidationErrorMessageDto:
      allOf:
        - $ref: '#/components/schemas/ErrorMessageDto'
        - type: object
          properties:
            errorCode:
              description: The error code
              type: string
              example: EXAMPLE_ERROR_CODE
            validationErrors:
              description: List of validation errors
              type: array
              items:
                $ref: '#/components/schemas/ValidationError'
            id:
              format: uuid
              description: The error identifier
              type: string
              example: 7958818d-64d2-4ede-b12b-4786dd2f348b
            message:
              description: The error message
              type: string
              example: Example error message
      type: object
      required:
        - errorCode
        - id
        - message
    ErrorMessageDto:
      type: object
      required:
        - errorCode
        - id
        - message
      properties:
        errorCode:
          description: The error code
          type: string
          example: EXAMPLE_ERROR_CODE
        id:
          format: uuid
          description: The error identifier
          type: string
          example: 7958818d-64d2-4ede-b12b-4786dd2f348b
        message:
          description: The error message
          type: string
          example: Example error message
    ConsumptionResponse:
      description: Elements in the page. If there is no elements the list will be empty.
      type: object
      required:
        - endDate
        - startDate
      properties:
        endDate:
          format: date-time
          description: The timestamp of the end of price interval.
          type: string
          example: '2023-11-26T05:05:00Z'
        consumption:
          description: The consumption in that interval in kWh.
          type: number
          example: 2.23
        startDate:
          format: date-time
          description: The timestamp of the start of the price interval.
          type: string
          example: '2023-11-26T05:00:00Z'
    ValidationError:
      type: object
      properties:
        field:
          description: Affected field
          type: string
        message:
          description: Validation message
          type: string
  examples:
    BAD_REQUEST:
      value:
        errorCode: BAD_REQUEST
        validationErrors:
          - field: Affected field
            message: Validation message
        id: 1068eb9d-7814-491b-8219-25bad554bef7
        message: Bad request
    UNAUTHORIZED:
      value:
        errorCode: UNAUTHORIZED
        id: 1068eb9d-7814-491b-8219-25bad554bef7
        message: Unauthorized
    TARIFF_NOT_FOUND:
      value:
        errorCode: TARIFF_NOT_FOUND
        id: 1068eb9d-7814-491b-8219-25bad554bef7
        message: '[TARIFF] Tariff not found.'
    VENDOR_ACCOUNT_IS_DISCONNECTED:
      value:
        errorCode: VENDOR_ACCOUNT_IS_DISCONNECTED
        id: 1068eb9d-7814-491b-8219-25bad554bef7
        message: '[VENDOR_ACCOUNT] Vendor account is disconnected'
    VENDOR_COMMUNICATION_ERROR:
      value:
        errorCode: VENDOR_COMMUNICATION_ERROR
        id: 1068eb9d-7814-491b-8219-25bad554bef7
        message: '[VENDOR API] Communication error with Vendor API'
    VENDOR_AUTHENTICATION_ERROR:
      value:
        errorCode: VENDOR_AUTHENTICATION_ERROR
        id: 1068eb9d-7814-491b-8219-25bad554bef7
        message: '[VENDOR API] Authentication error with Vendor API'
    VENDOR_CONNECTION_ERROR:
      value:
        errorCode: VENDOR_CONNECTION_ERROR
        id: 1068eb9d-7814-491b-8219-25bad554bef7
        message: '[VENDOR API] Connection cannot be established with Vendor API'
  securitySchemes:
    API_Key:
      in: header
      name: X-API-KEY
      description: API key used for authorization and authentication.
      type: apiKey

````