> ## Documentation Index
> Fetch the complete documentation index at: https://docs.datanumia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Returns the analysis for a target

> returns the analysis for a target



## OpenAPI

````yaml /api-reference/targets.yaml get /v2/sites/{siteId}/targets-analysis
openapi: 3.0.3
info:
  title: Targets lifecycle
  description: >
    Target key concepts:

    - A target is applicable for 12 months and spans from the start of the year
    to its end.

    - A target can either be a cost in euros or a consumption in kWh. The value
    of the target can be updated but not its unit type.
  termsOfService: TODO
  contact:
    email: api@datanumia.com
  version: 2.0.0
servers:
  - url: https://api.home.datanumia.com/api
    description: Production Server
security: []
paths:
  /v2/sites/{siteId}/targets-analysis:
    get:
      tags:
        - targets
      summary: Returns the analysis for a target
      description: returns the analysis for a target
      operationId: getTargetsAnalysis
      parameters:
        - name: siteId
          in: path
          required: true
          schema:
            type: string
          example: d8a9b286-d7c0-493c-9610-403747687023_01
        - name: targetIds
          in: query
          description: Target ids to keep when returning the analysis
          required: true
          schema:
            type: array
            items:
              type: string
          example:
            - 2FD7EADA83E24121C5EC0CFCBBEBCF819E08BDD845163E1C9D451737CC12BCFC
            - DTGDG424121C5EC0CFCBBEBCF819E08BDD845163E1C9D451737CC12BCFC
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetTargetsAnalysis'
        '400':
          description: |
            Functional Error.
            Error cases:
            - SITE_NOT_FOUND when the site referenced in the path doesn't exist
            - "FUNCTIONAL_EXCEPTION : No target analysis summary found"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                errorCode: SITE_NOT_FOUND
                errorDescription: Unknown site
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseUnauthorized'
        '403':
          description: Forbidden
          content: {}
        '404':
          description: Not Found
          content: {}
        '500':
          description: Server error
          content: {}
      security:
        - Bearer:
            - home:consumption-targets:targets-analysis:read
components:
  schemas:
    GetTargetsAnalysis:
      type: object
      properties:
        targetsOngoingAnalysis:
          $ref: '#/components/schemas/TargetOngoingAnalysisDTO'
        targetsEndedAnalysis:
          type: array
          items:
            $ref: '#/components/schemas/TargetEndedAnalysisDTO'
        errorMessages:
          type: array
          items:
            type: string
    ErrorResponse:
      required:
        - errorCode
        - errorDescription
      type: object
      properties:
        errorCode:
          description: The error code.
          type: string
          example: SITE_NOT_FOUND
        errorDescription:
          type: string
          description: The error description
          example: Unknown site
      description: ErrorResponse
    ErrorResponseUnauthorized:
      required:
        - errorCode
        - errorDescription
      type: object
      properties:
        errorCode:
          description: The error code.
          type: string
          example: INVALID_AUTHORIZATION_HEADER_VALUE
        errorDescription:
          type: string
          description: The error description
          example: The Authorization header is invalid
      description: ErrorResponse
    TargetOngoingAnalysisDTO:
      type: object
      required:
        - TargetDTO
        - analysis
      properties:
        targetDTO:
          $ref: '#/components/schemas/TargetDTO'
        analysis:
          $ref: '#/components/schemas/AnalysisDTO'
    TargetEndedAnalysisDTO:
      type: object
      required:
        - targetDTO
        - isSuccess
        - consumptions
      properties:
        targetDTO:
          $ref: '#/components/schemas/TargetDTO'
        isSuccess:
          type: string
        consumptions:
          type: array
          items:
            $ref: '#/components/schemas/ConsumptionDTO'
    TargetDTO:
      type: object
      required:
        - targetId
        - generationTs
        - beginDate
        - endDate
        - type
        - unit
        - targetValue
        - targetValueEquivalent
        - defaultTargetValue
        - defaultTargetValueEquivalent
        - isActive
        - notificationChannels
        - notificationType
        - name
      properties:
        targetId:
          description: Target id
          type: string
          example: 2FD7EADA83E24121C5EC0CFCBBEBCF819E08BDD845163E1C9D451737CC12BCFC
        generationTs:
          description: The generation timestamp for the target
          type: string
          format: date-time
          example: '2021-07-21T22:00:00Z'
        beginDate:
          description: The timestamp at which the target period starts
          type: string
          format: date-time
          example: '2021-12-31T23:00:00Z'
        endDate:
          description: The timestamp at which the target period ends
          type: string
          format: date-time
          example: '2022-12-31T23:00:00Z'
        type:
          description: The fluid type for the target (ELEC or CARBON)
          type: string
          example: ELEC
          enum:
            - ELEC
            - CARBON
        unit:
          description: >-
            The designated unit type for the target, which can be either EURO or
            KWH
          type: string
          example: EURO
          enum:
            - EURO
            - KWH
        targetValue:
          description: The yearly value for the target
          type: integer
          example: 3000
        targetValueEquivalent:
          description: The yearly value for the target, once converted to the other unit
          type: integer
          example: 12000
        defaultTargetValue:
          description: >-
            The yearly default value for the target; the reference value based
            on similar homes or past consumptions
          type: integer
          example: 3300
        defaultTargetValueEquivalent:
          description: >-
            The yearly default value for the target, once converted to the other
            unit
          type: integer
          example: 13200
        isActive:
          description: Flag set to true when the target period is ongoing
          type: boolean
          example: true
        notificationChannels:
          description: |
            The channels used to send notifications (EMAIL, SMS, both or none)
          type: array
          items:
            type: string
          example: []
        notificationType:
          description: >
            The condition that defines whether a notification should be sent or
            not
          type: string
          enum:
            - NONE
            - ON_DIST_INDEX_RECEPTION
            - THRESHOLD_OVERRUN
          example: NONE
        name:
          description: The target's name
          type: string
          example: My target
    AnalysisDTO:
      type: object
      required:
        - mainTargetAnalysisCase
        - detailedTargetAnalysisCase
        - beginDate
        - endDate
        - analyseGenerationDate
        - estimatedValueOnPeriod
        - estimatedValueOnPeriodEquivalent
        - realValueOnPeriod
        - realValueOnPeriodEquivalent
        - estimatedValueOnLastMonths
        - estimatedValueOnLastMonthsEquivalent
        - realValueOnLastMonths
        - realValueOnLastMonthsEquivalent
        - costDifferenceRateOnPeriod
        - costDifferenceRateOnPeriodEquivalent
        - estimatedValueTotal
        - estimatedValueTotalEquivalent
        - unit
      properties:
        mainTargetAnalysisCase:
          description: Availability of the analysis
          type: string
          enum:
            - NO_TARGET
            - ANALYSIS_AVAILABLE_ON_ONGOING_YEAR
            - ANALYSIS_AVAILABLE_ON_ENDED_PERIOD
          example: ANALYSIS_AVAILABLE_ON_ONGOING_YEAR
        detailedTargetAnalysisCase:
          description: Result of the analysis
          type: string
          example: ONYEAR-BAD
        beginDate:
          description: The beginning of the analysis period
          type: string
          format: date-time
          example: '2021-12-31T23:00:00Z'
        endDate:
          description: The end of the analysis period
          type: string
          format: date-time
          example: '2022-12-31T23:00:00Z'
        analyseGenerationDate:
          description: The date at which the analysis was generated
          type: string
          format: date-time
          example: '2021-07-21T22:00:00Z'
        estimatedValueOnPeriod:
          description: the expected consumption/cost on the available period
          type: number
          example: 300
        estimatedValueOnPeriodEquivalent:
          description: the expected consumption/cost on the available period (other unit)
          type: number
          example: 1200
        realValueOnPeriod:
          description: the real consumption/cost on the available period
          type: number
          example: 330
        realValueOnPeriodEquivalent:
          description: the real consumption/cost on the available period (other unit)
          type: number
          example: 1320
        estimatedValueOnLastMonths:
          description: the expected consumption/cost on the last two subperiods
          type: number
          example: 150
        estimatedValueOnLastMonthsEquivalent:
          description: >-
            the expected consumption/cost on the last two subperiods (other
            unit)
          type: number
          example: 600
        realValueOnLastMonths:
          description: the real consumption/cost on the last two subperiods
          type: number
          example: 165
        realValueOnLastMonthsEquivalent:
          description: the real consumption/cost on the last two subperiods (other unit)
          type: number
          example: 660
        costDifferenceRateOnPeriod:
          description: >-
            the difference rate between the expected and real consumptions/costs
            on the available period
          type: number
          example: 10
        costDifferenceRateOnPeriodEquivalent:
          description: >-
            the difference rate between the expected and real consumptions/costs
            on the available period (other unit)
          type: number
          example: 10
        estimatedValueTotal:
          description: estimatedValueTotal
          type: number
          example: 120
        estimatedValueTotalEquivalent:
          description: estimatedValueTotalEquivalent
          type: number
          example: 55.5
        unit:
          description: Unit selected for the target (KWH or EURO)
          type: string
          enum:
            - EURO
            - KWH
          example: EURO
    ConsumptionDTO:
      type: object
      required:
        - period
        - energyMeter
        - cost
        - quality
        - errorFlags
        - indexNatures
        - status
        - nature
        - aggregated
        - usingLoadCurve
      properties:
        period:
          $ref: '#/components/schemas/ZonedTimePeriodDto'
        energyMeter:
          $ref: '#/components/schemas/ConsumptionEnergyMeterDto'
        cost:
          $ref: '#/components/schemas/ConsumptionCostDto'
        quality:
          type: number
          example: 0.0063257776
        errorFlags:
          type: array
          items:
            type: string
            enum:
              - BAD_INDEX_INFORMATION_OR_CONTRACT_CHANGE_MISSING
              - ABERRANT_CONSUMPTION
        indexNatures:
          type: array
          items:
            type: string
            enum:
              - LINKY_OK
              - LINKY_INTERPOLE
              - LINKY_SUJET_A_CAUTION
              - DISTRIBUTEUR
              - DISTRIBUTEUR_INVALIDE
              - MKT_SENSOR
              - MKT_SENSOR_INVALIDE
              - STEREO
              - RELEVE_CONFIANCE
              - RELEVE_CONFIANCE_INVALIDE
              - SCORE_RC
              - SCORE_RC_ACQUITTE
              - SCORE_RC_INVALIDE
              - SCORE_RC_INVALIDE_APPLIANCE
              - SCORE
              - SCORE_ACQUITTE
              - SCORE_INVALIDE_EDE
              - SCORE_INVALIDE_ACP
              - SCORE_INVALIDE_USER
              - SCORE_INVALIDE_APPLIANCE
              - SUIVI_CONSO
              - SUIVI_CONSO_INVALIDE
              - ESTI_EDELIA
              - ESTI_ACC
              - ESTI_ACC_INVALIDE
              - SCORE_INVALIDE_TRV_OM
          example:
            - LINKY_OK
            - SUIVI_CONSO
        status:
          type: string
          enum:
            - EMPTY
            - INCOMPLETE
            - COMPLETE
          example: COMPLETE
        nature:
          type: string
          enum:
            - REAL
            - ESTIMATED
            - SENSOR
            - EMPTY
          example: REAL
        aggregated:
          type: boolean
          example: false
        usingLoadCurve:
          type: boolean
          example: true
    ZonedTimePeriodDto:
      description: The period from which consumption was fetched
      type: object
      required:
        - startTime
        - endTime
      properties:
        startTime:
          type: string
          format: date-time
          example: '2021-12-31T22:00:00Z'
        endTime:
          type: string
          format: date-time
          example: '2022-12-31T22:00:00Z'
    ConsumptionEnergyMeterDto:
      description: The energy component of the consumption (total and by tariff heading)
      type: object
      required:
        - total
        - byTariffHeading
      properties:
        total:
          type: number
          example: 1320
        byTariffHeading:
          description: Energy consumption for each tariff heading
          additionalProperties:
            $ref: '#/components/schemas/ConsumptionPerTariffHeading'
          example:
            HP: 1200
            HC: 120
    ConsumptionCostDto:
      description: The cost component of the consumption (total and by tariff heading)
      type: object
      required:
        - total
        - standingCharge
        - standingChargeByComponents
        - byTariffHeading
      properties:
        total:
          description: total cost (includes standing charges)
          type: number
          example: 330
        standingCharge:
          description: total cost of standing charges
          type: number
          example: 25
        standingChargeByComponents:
          description: Standing charges for each component
          additionalProperties:
            $ref: '#/components/schemas/StandingChargeByComponents'
            example: {}
        byTariffHeading:
          description: Cost for each tariff heading
          additionalProperties:
            $ref: '#/components/schemas/CostPerTariffHeading'
          example:
            HP: 300
            HC: 30
    ConsumptionPerTariffHeading:
      type: object
      properties:
        component:
          type: string
          description: |
            Tariff heading
          example: HC
        consumption:
          type: number
          description: |
            Consumption
          example: 2.325913978494624
    StandingChargeByComponents:
      type: object
      properties:
        component:
          type: string
          description: |
            Component name
          example: HC
        standingCharge:
          type: number
          description: |
            Standing charge
          example: 1
    CostPerTariffHeading:
      type: object
      properties:
        component:
          type: string
          description: |
            Tariff heading
          example: HC
        standingCharge:
          type: number
          description: |
            Cost
          example: 0.3259139784946237
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````