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

# Retrieve Site Stats Over a Date Range

> Fetches time-series performance metrics (CPU, memory, disk, uptime) for a site within a specified date range. For ranges over 48 hours, data is automatically aggregated hourly to ensure a fast response. For shorter ranges, raw data points are returned.



## OpenAPI

````yaml /api/en/mikrotik-api.yaml get /sites/{siteId}/mikrotik-stats
openapi: 3.0.3
info:
  title: Altostrat MikroTik Devices API
  version: 1.0.0
  description: >-
    The Altostrat MikroTik Devices API is the microservice responsible for
    managing the lifecycle, configuration, and real-time state of MikroTik
    devices within the SDX platform.


    It acts as the command and control plane for individual network endpoints,
    receiving heartbeats, dispatching jobs, and providing observability into
    device health. This service is the bridge between the Altostrat SDX
    automation layer and the physical network hardware.


    This API allows you to programmatically manage:

    - **Sites:** The digital twin of a physical MikroTik router, representing
    its identity, configuration, and current online status.

    - **Jobs:** Asynchronous commands or scripts sent to a Site for execution,
    enabling remote configuration changes, troubleshooting, and automation.

    - **Device Stats:** Time-series performance data, including CPU load, memory
    usage, and uptime, collected from each Site.


    Developers use this API to programmatically list, monitor, and interact with
    their fleet of MikroTik devices, forming the basis for building custom
    network automation and management tools.
servers:
  - url: https://v1.api.altostrat.io
    description: Production API Server
security:
  - BearerAuth: []
tags:
  - name: Sites
    description: Manage and monitor MikroTik devices, referred to as "Sites".
  - name: Jobs
    description: Create and manage asynchronous commands to be executed on Sites.
  - name: Device Stats
    description: Retrieve time-series performance metrics from Sites.
  - name: Runbooks
    description: Access device onboarding configurations.
  - name: Developer API
    description: >-
      Run synchronous RouterOS commands or queue asynchronous RouterOS scripts
      through SDX.
  - name: Developer Routers
    description: Read router-level summaries exposed by the SDX developer API.
paths:
  /sites/{siteId}/mikrotik-stats:
    get:
      tags:
        - Device Stats
      summary: Retrieve Site Stats Over a Date Range
      description: >-
        Fetches time-series performance metrics (CPU, memory, disk, uptime) for
        a site within a specified date range. For ranges over 48 hours, data is
        automatically aggregated hourly to ensure a fast response. For shorter
        ranges, raw data points are returned.
      parameters:
        - name: siteId
          in: path
          required: true
          description: The UUID of the site.
          schema:
            type: string
            format: uuid
        - name: start_date
          in: query
          required: true
          description: The start date for the query range (inclusive).
          schema:
            type: string
            format: date
            example: '2025-10-28'
        - name: end_date
          in: query
          required: true
          description: The end date for the query range (inclusive).
          schema:
            type: string
            format: date
            example: '2025-10-29'
      responses:
        '200':
          description: A list of performance metric snapshots.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/MikrotikStats'
        '400':
          description: Bad Request - The date range is invalid or missing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: invalid_request_error
                code: parameter_invalid
                message: The end_date must be the same or after the start_date.
                doc_url: https://docs.altostrat.io/errors/parameter_invalid
        '404':
          description: Not Found - The requested site does not exist.
components:
  schemas:
    MikrotikStats:
      type: object
      description: >-
        A snapshot of a device's performance metrics at a specific point in
        time.
      properties:
        created_at:
          type: string
          format: date-time
          description: The timestamp when these stats were recorded.
          example: '2025-10-29T11:47:00Z'
        cpu_load:
          type: integer
          description: The CPU load percentage.
          example: 15
        memory_free:
          type: integer
          description: The amount of free memory in bytes.
          example: 876543210
        disk_free:
          type: integer
          description: The amount of free disk space in bytes.
          example: 123456789
        uptime:
          type: integer
          description: The device uptime in seconds.
          example: 312780
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          description: A broad category for the error (e.g., 'invalid_request_error').
          example: invalid_request_error
        code:
          type: string
          description: A short, unique string identifying the specific error.
          example: parameter_invalid
        message:
          type: string
          description: A human-readable description of what went wrong.
          example: The 'lat' parameter must be between -90 and 90.
        doc_url:
          type: string
          description: >-
            A direct link to the documentation page for this specific error
            code.
          example: https://docs.altostrat.io/errors/parameter_invalid
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Authenticate requests by providing a JSON Web Token (JWT) in the
        `Authorization` header. Example: `Authorization: Bearer <YOUR_JWT>`

````