{
  "swagger": "2.0",
  "info": {
    "title": "evey/v1/activity.proto",
    "version": "version not set"
  },
  "tags": [
    {
      "name": "ActivityService"
    }
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/api/v1/activity/history": {
      "get": {
        "operationId": "ActivityService_GetPlayHistory",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1GetPlayHistoryResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/rpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "profileId",
            "description": "profile_id: a non-admin caller may only ask for its own (anything else is\nPermissionDenied). An admin may ask for any profile, or leave it empty\ntogether with user_id to get the whole server's history.",
            "in": "query",
            "required": false,
            "type": "string"
          },
          {
            "name": "mediaItemId",
            "in": "query",
            "required": false,
            "type": "string"
          },
          {
            "name": "type",
            "description": " - MEDIA_ITEM_TYPE_BOOK: Deprecated: see LIBRARY_TYPE_BOOKS.",
            "in": "query",
            "required": false,
            "type": "string",
            "enum": [
              "MEDIA_ITEM_TYPE_UNSPECIFIED",
              "MEDIA_ITEM_TYPE_MOVIE",
              "MEDIA_ITEM_TYPE_SERIES",
              "MEDIA_ITEM_TYPE_SEASON",
              "MEDIA_ITEM_TYPE_EPISODE",
              "MEDIA_ITEM_TYPE_ALBUM",
              "MEDIA_ITEM_TYPE_ARTIST",
              "MEDIA_ITEM_TYPE_TRACK",
              "MEDIA_ITEM_TYPE_PHOTO",
              "MEDIA_ITEM_TYPE_BOOK"
            ],
            "default": "MEDIA_ITEM_TYPE_UNSPECIFIED"
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "pagination.page",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "pagination.pageSize",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "pagination.cursor",
            "description": "Opaque keyset cursor returned by a previous PaginationResponse. When\nset, server uses keyset pagination instead of offset and ignores\n`page` - guarantees no skips/duplicates under concurrent writes.",
            "in": "query",
            "required": false,
            "type": "string"
          },
          {
            "name": "userId",
            "description": "user_id narrows to every profile of one account. Admin-only; ignored for\nanyone else.",
            "in": "query",
            "required": false,
            "type": "string"
          }
        ],
        "tags": [
          "ActivityService"
        ]
      }
    },
    "/api/v1/activity/logins": {
      "get": {
        "operationId": "ActivityService_GetLoginHistory",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1GetLoginHistoryResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/rpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "query",
            "required": false,
            "type": "string"
          },
          {
            "name": "successOnly",
            "in": "query",
            "required": false,
            "type": "boolean"
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "pagination.page",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "pagination.pageSize",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "pagination.cursor",
            "description": "Opaque keyset cursor returned by a previous PaginationResponse. When\nset, server uses keyset pagination instead of offset and ignores\n`page` - guarantees no skips/duplicates under concurrent writes.",
            "in": "query",
            "required": false,
            "type": "string"
          }
        ],
        "tags": [
          "ActivityService"
        ]
      }
    },
    "/api/v1/activity/metrics": {
      "get": {
        "operationId": "ActivityService_ListServerMetrics",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1ListServerMetricsResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/rpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "from",
            "description": "Defaults: the last 24 hours.",
            "in": "query",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "intervalSeconds",
            "description": "Width of the buckets the samples are folded into. 0 lets the server\npick one that keeps the window under a few hundred points; a given\nvalue is rounded up to the nearest step the server uses.",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          }
        ],
        "tags": [
          "ActivityService"
        ]
      }
    },
    "/api/v1/activity/page-view": {
      "post": {
        "summary": "RecordPageView logs a client-side navigation as an audit entry\n(action \"page_view\", resource \"page\"), so admins can see which pages\nusers visit. Best-effort; the client dedups/throttles.",
        "operationId": "ActivityService_RecordPageView",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1RecordPageViewResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/rpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/v1RecordPageViewRequest"
            }
          }
        ],
        "tags": [
          "ActivityService"
        ]
      }
    },
    "/api/v1/activity/stats/server": {
      "get": {
        "operationId": "ActivityService_GetServerStats",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1ServerStats"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/rpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "popularLimit",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "activeUsersLimit",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          }
        ],
        "tags": [
          "ActivityService"
        ]
      }
    },
    "/api/v1/activity/stats/user/{profileId}": {
      "get": {
        "operationId": "ActivityService_GetUserStats",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1UserStats"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/rpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "profileId",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "type": "string",
            "format": "date-time"
          },
          {
            "name": "mostPlayedLimit",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          }
        ],
        "tags": [
          "ActivityService"
        ]
      }
    },
    "/api/v1/admin/analytics": {
      "get": {
        "operationId": "ActivityService_GetAnalytics",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1GetAnalyticsResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/rpcStatus"
            }
          }
        },
        "tags": [
          "ActivityService"
        ]
      }
    },
    "/api/v1/popular": {
      "get": {
        "operationId": "ActivityService_GetPopularMedia",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1GetPopularMediaResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/rpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "type": "integer",
            "format": "int32"
          }
        ],
        "tags": [
          "ActivityService"
        ]
      }
    }
  },
  "definitions": {
    "protobufAny": {
      "type": "object",
      "properties": {
        "@type": {
          "type": "string"
        }
      },
      "additionalProperties": {}
    },
    "rpcStatus": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/protobufAny"
          }
        }
      }
    },
    "v1ActiveUser": {
      "type": "object",
      "properties": {
        "userId": {
          "type": "string"
        },
        "username": {
          "type": "string"
        },
        "playCount": {
          "type": "integer",
          "format": "int32"
        },
        "totalWatchTimeMs": {
          "type": "string",
          "format": "int64"
        },
        "lastActiveAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "v1AnalyticsDailyPlayCount": {
      "type": "object",
      "properties": {
        "date": {
          "type": "string"
        },
        "playCount": {
          "type": "integer",
          "format": "int32"
        },
        "watchTimeSeconds": {
          "type": "string",
          "format": "int64"
        }
      }
    },
    "v1AnalyticsHourlyPlayCount": {
      "type": "object",
      "properties": {
        "hour": {
          "type": "integer",
          "format": "int32"
        },
        "count": {
          "type": "integer",
          "format": "int32"
        }
      }
    },
    "v1AnalyticsPlayMethod": {
      "type": "object",
      "properties": {
        "method": {
          "type": "string"
        },
        "count": {
          "type": "integer",
          "format": "int32"
        }
      }
    },
    "v1AnalyticsRecentActivity": {
      "type": "object",
      "properties": {
        "userId": {
          "type": "string"
        },
        "username": {
          "type": "string"
        },
        "mediaTitle": {
          "type": "string"
        },
        "playedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "v1AnalyticsTopMedia": {
      "type": "object",
      "properties": {
        "mediaItemId": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "playCount": {
          "type": "integer",
          "format": "int32"
        },
        "totalDurationSeconds": {
          "type": "string",
          "format": "int64"
        }
      }
    },
    "v1GenreBreakdown": {
      "type": "object",
      "properties": {
        "genre": {
          "type": "string"
        },
        "totalTimeMs": {
          "type": "string",
          "format": "int64"
        },
        "playCount": {
          "type": "integer",
          "format": "int32"
        },
        "percent": {
          "type": "number",
          "format": "double"
        }
      }
    },
    "v1GetAnalyticsResponse": {
      "type": "object",
      "properties": {
        "topMedia": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1AnalyticsTopMedia"
          }
        },
        "recentActivity": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1AnalyticsRecentActivity"
          }
        },
        "totalPlaysToday": {
          "type": "integer",
          "format": "int32"
        },
        "totalPlaysThisWeek": {
          "type": "integer",
          "format": "int32"
        },
        "activeUsersToday": {
          "type": "integer",
          "format": "int32"
        },
        "dailyPlays": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1AnalyticsDailyPlayCount"
          }
        },
        "playMethods": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1AnalyticsPlayMethod"
          }
        },
        "hourlyPlays": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1AnalyticsHourlyPlayCount"
          }
        }
      }
    },
    "v1GetLoginHistoryResponse": {
      "type": "object",
      "properties": {
        "entries": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1LoginEntry"
          }
        },
        "pagination": {
          "$ref": "#/definitions/v1PaginationResponse"
        }
      }
    },
    "v1GetPlayHistoryResponse": {
      "type": "object",
      "properties": {
        "entries": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1PlayHistoryEntry"
          }
        },
        "pagination": {
          "$ref": "#/definitions/v1PaginationResponse"
        }
      }
    },
    "v1GetPopularMediaResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1PopularMediaItem"
          }
        }
      }
    },
    "v1ListServerMetricsResponse": {
      "type": "object",
      "properties": {
        "metrics": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1ServerMetric"
          },
          "description": "One point per bucket: percentages and rates averaged, counts, disk wait\nand storage at their maximum, disk_busiest the most frequent name."
        },
        "intervalSeconds": {
          "type": "integer",
          "format": "int32",
          "description": "The bucket width actually applied."
        },
        "idleDiskAwaitMs": {
          "type": "number",
          "format": "double",
          "description": "The disks' wait at rest over the last day (floored at 4 ms) and the wait\nabove which a sample counts as saturated: the two reference lines a\nchart draws under disk_await_ms."
        },
        "saturationAwaitMs": {
          "type": "number",
          "format": "double"
        }
      }
    },
    "v1LoginEntry": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "userId": {
          "type": "string"
        },
        "username": {
          "type": "string"
        },
        "ipAddress": {
          "type": "string"
        },
        "userAgent": {
          "type": "string"
        },
        "success": {
          "type": "boolean"
        },
        "failureReason": {
          "type": "string"
        },
        "timestamp": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "v1MediaItemType": {
      "type": "string",
      "enum": [
        "MEDIA_ITEM_TYPE_UNSPECIFIED",
        "MEDIA_ITEM_TYPE_MOVIE",
        "MEDIA_ITEM_TYPE_SERIES",
        "MEDIA_ITEM_TYPE_SEASON",
        "MEDIA_ITEM_TYPE_EPISODE",
        "MEDIA_ITEM_TYPE_ALBUM",
        "MEDIA_ITEM_TYPE_ARTIST",
        "MEDIA_ITEM_TYPE_TRACK",
        "MEDIA_ITEM_TYPE_PHOTO",
        "MEDIA_ITEM_TYPE_BOOK"
      ],
      "default": "MEDIA_ITEM_TYPE_UNSPECIFIED",
      "description": " - MEDIA_ITEM_TYPE_BOOK: Deprecated: see LIBRARY_TYPE_BOOKS."
    },
    "v1MonthlyPlayCount": {
      "type": "object",
      "properties": {
        "year": {
          "type": "integer",
          "format": "int32"
        },
        "month": {
          "type": "integer",
          "format": "int32"
        },
        "playCount": {
          "type": "integer",
          "format": "int32"
        },
        "totalTimeMs": {
          "type": "string",
          "format": "int64"
        }
      }
    },
    "v1MostPlayed": {
      "type": "object",
      "properties": {
        "mediaItemId": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "type": {
          "$ref": "#/definitions/v1MediaItemType"
        },
        "playCount": {
          "type": "integer",
          "format": "int32"
        },
        "totalTimeMs": {
          "type": "string",
          "format": "int64"
        }
      }
    },
    "v1PaginationRequest": {
      "type": "object",
      "properties": {
        "page": {
          "type": "integer",
          "format": "int32"
        },
        "pageSize": {
          "type": "integer",
          "format": "int32"
        },
        "cursor": {
          "type": "string",
          "description": "Opaque keyset cursor returned by a previous PaginationResponse. When\nset, server uses keyset pagination instead of offset and ignores\n`page` - guarantees no skips/duplicates under concurrent writes."
        }
      }
    },
    "v1PaginationResponse": {
      "type": "object",
      "properties": {
        "page": {
          "type": "integer",
          "format": "int32"
        },
        "pageSize": {
          "type": "integer",
          "format": "int32"
        },
        "totalItems": {
          "type": "integer",
          "format": "int32"
        },
        "totalPages": {
          "type": "integer",
          "format": "int32"
        },
        "nextCursor": {
          "type": "string",
          "description": "Opaque cursor for the next page. Empty when no more pages or when\nthe server fell back to offset pagination."
        }
      }
    },
    "v1PlayHistoryEntry": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "profileId": {
          "type": "string"
        },
        "mediaItemId": {
          "type": "string"
        },
        "mediaTitle": {
          "type": "string"
        },
        "mediaType": {
          "$ref": "#/definitions/v1MediaItemType"
        },
        "durationMs": {
          "type": "string",
          "format": "int64"
        },
        "positionMs": {
          "type": "string",
          "format": "int64"
        },
        "completed": {
          "type": "boolean"
        },
        "deviceName": {
          "type": "string"
        },
        "clientName": {
          "type": "string"
        },
        "playMethod": {
          "type": "string"
        },
        "startedAt": {
          "type": "string",
          "format": "date-time"
        },
        "endedAt": {
          "type": "string",
          "format": "date-time"
        },
        "profileName": {
          "type": "string",
          "description": "Who watched. Resolved by JOIN, never persisted on the session row: an\nadmin reading the server-wide history needs a name, not a profile UUID.\nEmpty for a profile that has since been deleted."
        },
        "userId": {
          "type": "string"
        },
        "username": {
          "type": "string"
        }
      }
    },
    "v1PopularMedia": {
      "type": "object",
      "properties": {
        "mediaItemId": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "type": {
          "$ref": "#/definitions/v1MediaItemType"
        },
        "playCount": {
          "type": "integer",
          "format": "int32"
        },
        "uniqueViewers": {
          "type": "integer",
          "format": "int32"
        }
      }
    },
    "v1PopularMediaItem": {
      "type": "object",
      "properties": {
        "mediaItemId": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "playCount": {
          "type": "integer",
          "format": "int32"
        }
      }
    },
    "v1RecordPageViewRequest": {
      "type": "object",
      "properties": {
        "path": {
          "type": "string"
        }
      }
    },
    "v1RecordPageViewResponse": {
      "type": "object"
    },
    "v1ServerMetric": {
      "type": "object",
      "properties": {
        "timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "cpuPercent": {
          "type": "number",
          "format": "double"
        },
        "memoryPercent": {
          "type": "number",
          "format": "double"
        },
        "memoryUsedBytes": {
          "type": "string",
          "format": "int64"
        },
        "networkRxBytes": {
          "type": "string",
          "format": "int64",
          "description": "Never filled: the sampler records rates, see network_rx_bps/tx_bps."
        },
        "networkTxBytes": {
          "type": "string",
          "format": "int64"
        },
        "activeStreams": {
          "type": "integer",
          "format": "int32"
        },
        "activeTranscodes": {
          "type": "integer",
          "format": "int32"
        },
        "memoryTotalBytes": {
          "type": "string",
          "format": "int64"
        },
        "bandwidthBps": {
          "type": "string",
          "format": "int64",
          "description": "Streaming bits per second Evey served over the sample."
        },
        "storageUsedBytes": {
          "type": "string",
          "format": "int64"
        },
        "storageTotalBytes": {
          "type": "string",
          "format": "int64"
        },
        "iowaitPercent": {
          "type": "number",
          "format": "double",
          "description": "The machine's share of CPU time spent waiting on a disk; cpu_percent\ncounts that time as idle."
        },
        "diskAwaitMs": {
          "type": "number",
          "format": "double",
          "description": "The disk that waited the most over the sample: its mean read wait,\nits busy share and its stable label (model and serial tail, never the\nkernel letter). Whole machine figures, not Evey's alone."
        },
        "diskUtilPercent": {
          "type": "number",
          "format": "double"
        },
        "diskBusiest": {
          "type": "string"
        },
        "diskReadBps": {
          "type": "string",
          "format": "int64",
          "description": "Summed over every physical disk."
        },
        "diskWriteBps": {
          "type": "string",
          "format": "int64"
        },
        "networkRxBps": {
          "type": "string",
          "format": "int64",
          "description": "Every interface but the loopback, streaming or not."
        },
        "networkTxBps": {
          "type": "string",
          "format": "int64"
        }
      }
    },
    "v1ServerStats": {
      "type": "object",
      "properties": {
        "totalPlays": {
          "type": "integer",
          "format": "int32",
          "description": "All-time number of play sessions."
        },
        "totalBandwidthBytes": {
          "type": "string",
          "format": "int64",
          "description": "Streaming bytes actually served, integrated from the periodic\nserver-metric samples (real measurement, accumulates from the moment the\nsampler first ran - bounded by EVEY_METRICS_RETENTION_DAYS)."
        },
        "popularMedia": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1PopularMedia"
          },
          "description": "Top played items over the last 90 days."
        },
        "activeUsers": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1ActiveUser"
          },
          "description": "Most active users over the last 30 days."
        },
        "totalUsers": {
          "type": "integer",
          "format": "int32"
        },
        "totalMediaItems": {
          "type": "integer",
          "format": "int32"
        },
        "totalStorageBytes": {
          "type": "string",
          "format": "int64",
          "description": "Total on-disk size of every media file in the catalog."
        },
        "totalPlayTimeMs": {
          "type": "string",
          "format": "int64",
          "description": "All-time cumulative watch time across every session."
        }
      }
    },
    "v1UserStats": {
      "type": "object",
      "properties": {
        "profileId": {
          "type": "string"
        },
        "totalWatchTimeMs": {
          "type": "string",
          "format": "int64"
        },
        "totalPlays": {
          "type": "integer",
          "format": "int32"
        },
        "genres": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1GenreBreakdown"
          }
        },
        "mostPlayed": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1MostPlayed"
          }
        },
        "byMonth": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/v1MonthlyPlayCount"
          }
        },
        "uniqueItemsWatched": {
          "type": "integer",
          "format": "int32"
        }
      }
    }
  }
}
