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

# Get Public Sensor Data

> Mengambil data sensor berdasarkan rentang waktu menggunakan APIKey ID tanpa autentikasi.



## OpenAPI

````yaml GET /{api-key}/devices/{device_id}/data
openapi: 3.0.3
info:
  title: Mertani External API
  version: 3.0.0
  description: API untuk akses data perangkat IoT Mertani
servers:
  - url: https://app.mertani.co.id/external/v1
security: []
tags:
  - name: Devices
    description: Device management
  - name: Sensor Data
    description: Sensor readings
paths:
  /{api-key}/devices/{device_id}/data:
    get:
      tags:
        - Sensor Data
      summary: Get device sensor data (Public Access)
      description: >-
        Mengambil data sensor berdasarkan rentang waktu menggunakan APIKey ID
        tanpa autentikasi.
      operationId: getDeviceSensorDataByAPIKey
      parameters:
        - name: api-key
          in: path
          required: true
          schema:
            type: string
          description: API Key untuk akses publik
          example: mertani-abc123
        - name: device_id
          in: path
          required: true
          schema:
            type: string
        - name: start
          in: query
          required: false
          schema:
            type: string
            format: date-time
            default: null
          description: >-
            Timestamp awal data (ISO 8601). Jika tidak diisi, default hari ini
            jam 00:00:00. Format: YYYY-MM-DDTHH:MM:SSZ
          example: '2026-05-05T00:00:00Z'
        - name: end
          in: query
          required: false
          schema:
            type: string
            format: date-time
            default: null
          description: >-
            Timestamp akhir data (ISO 8601). Jika tidak diisi, default waktu
            sekarang. Format: YYYY-MM-DDTHH:MM:SSZ
          example: '2026-05-05T23:59:59Z'
        - name: tz
          in: query
          required: false
          schema:
            type: integer
          example: 7
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetSensorDataResponse'
              examples:
                success:
                  summary: Contoh response sukses
                  value:
                    message: Success
                    data:
                      - timestamp: '2026-05-05T07:00:00+07:00'
                        sensors:
                          - id: DEV001-sig
                            value: 15
                            unit: .
                          - id: DEV001-batt
                            value: 92
                            unit: '%'
                          - id: DEV001-flTemp
                            value: 29.8
                            unit: C
                          - id: DEV001-flLev
                            value: 152.45
                            unit: cm
        '400':
          $ref: '#/components/responses/BadRequest'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '405':
          $ref: '#/components/responses/MethodNotAllowed'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  schemas:
    GetSensorDataResponse:
      type: object
      properties:
        message:
          type: string
          example: Success
        data:
          type: array
          items:
            $ref: '#/components/schemas/SensorDataItem'
    SensorDataItem:
      type: object
      properties:
        timestamp:
          type: string
          format: date-time
        sensors:
          type: array
          items:
            $ref: '#/components/schemas/SensorValue'
    SensorValue:
      type: object
      properties:
        id:
          type: string
        value:
          type: number
        unit:
          type: string
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          example:
            message: Bad Request
            data: null
    Forbidden:
      description: Forbidden
      content:
        application/json:
          example:
            message: Forbidden
            data: null
    NotFound:
      description: Device not found
      content:
        application/json:
          example:
            message: Device not found
            data: null
    MethodNotAllowed:
      description: Method Not Allowed
      content:
        application/json:
          example:
            message: Method Not Allowed
            data: null
    TooManyRequests:
      description: Too Many Requests
      content:
        application/json:
          example:
            message: To Many Request
            data: null

````