{
  "openapi": "3.0.1",
  "info": {
    "title": "Effort Tracker Public API",
    "description": "Public read-only API for querying effort tracking data from Azure DevOps. Authenticate using your Azure DevOps Personal Access Token (PAT).",
    "contact": {
      "name": "Sinaware",
      "url": "https://efforttracker.sinaware.com"
    },
    "license": {
      "name": "Commercial",
      "url": "https://efforttracker.sinaware.com/terms.html"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://efforttrackerapi.sinaware.com/api"
    }
  ],
  "paths": {
    "/v1/activitytypes": {
      "get": {
        "tags": [
          "Activity Types"
        ],
        "summary": "Get activity types",
        "description": "Get all active activity types for the organization.",
        "operationId": "GetActivityTypes",
        "parameters": [
          {
            "name": "X-Organization",
            "in": "header",
            "description": "Azure DevOps organization name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "project",
            "in": "query",
            "description": "Optional project name to filter by",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/activityTypeListResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer_auth": [ ]
          }
        ]
      }
    },
    "/v1/effortlogs": {
      "get": {
        "tags": [
          "Effort Logs"
        ],
        "summary": "Get effort logs",
        "description": "Get paginated effort logs for a specific work item.",
        "operationId": "GetEffortLogs",
        "parameters": [
          {
            "name": "X-Organization",
            "in": "header",
            "description": "Azure DevOps organization name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workItemId",
            "in": "query",
            "description": "Work item ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number (default: 1)",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Page size (default: 50, max: 500)",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/effortLogListResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer_auth": [ ]
          }
        ]
      }
    },
    "/v1/effortlogs/query": {
      "post": {
        "tags": [
          "Effort Logs"
        ],
        "summary": "Query effort logs",
        "description": "Query effort logs with advanced filters including date range, users, areas, activity types, and work item IDs.",
        "operationId": "QueryEffortLogs",
        "parameters": [
          {
            "name": "X-Organization",
            "in": "header",
            "description": "Azure DevOps organization name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Query filters",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/effortLogQuery"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/effortLogListResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer_auth": [ ]
          }
        ]
      }
    },
    "/v1/effortlogs/export": {
      "get": {
        "tags": [
          "Effort Logs"
        ],
        "summary": "Export effort logs",
        "description": "Export effort logs as CSV or JSON. Rate limited to 10 requests per hour.",
        "operationId": "ExportEffortLogs",
        "parameters": [
          {
            "name": "X-Organization",
            "in": "header",
            "description": "Azure DevOps organization name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "description": "Export format: csv or json (default: json)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateFrom",
            "in": "query",
            "description": "Start date (YYYY-MM-DD)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "description": "End date (YYYY-MM-DD)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "usernames",
            "in": "query",
            "description": "Comma-separated usernames filter",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "areas",
            "in": "query",
            "description": "Comma-separated area paths filter",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "activityTypes",
            "in": "query",
            "description": "Comma-separated activity types filter",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "projects",
            "in": "query",
            "description": "Comma-separated project names filter",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "CSV export",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer_auth": [ ]
          }
        ]
      }
    },
    "/v1/stats/summary": {
      "get": {
        "tags": [
          "Statistics"
        ],
        "summary": "Get summary statistics",
        "description": "Get total records, hours, user count, and project count for the organization.",
        "operationId": "GetStatsSummary",
        "parameters": [
          {
            "name": "X-Organization",
            "in": "header",
            "description": "Azure DevOps organization name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/statsSummaryResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer_auth": [ ]
          }
        ]
      }
    },
    "/v1/stats/user-counts": {
      "get": {
        "tags": [
          "Statistics"
        ],
        "summary": "Get user log counts",
        "description": "Get the number of effort log entries per user.",
        "operationId": "GetUserCounts",
        "parameters": [
          {
            "name": "X-Organization",
            "in": "header",
            "description": "Azure DevOps organization name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "project",
            "in": "query",
            "description": "Optional project name to filter by",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/userLogCountListResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer_auth": [ ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "activityType": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "isActive": {
            "type": "boolean"
          },
          "displayOrder": {
            "type": "integer",
            "format": "int32"
          },
          "projectName": {
            "type": "string"
          }
        }
      },
      "activityTypeListResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/activityType"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/responseMeta"
          }
        }
      },
      "effortLog": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workItemId": {
            "type": "integer",
            "format": "int32"
          },
          "date": {
            "type": "string"
          },
          "hours": {
            "type": "number",
            "format": "double"
          },
          "activityType": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "userId": {
            "type": "string"
          },
          "userDisplayName": {
            "type": "string"
          },
          "projectName": {
            "type": "string"
          },
          "areaPath": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "effortLogListResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/effortLog"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/paginationInfo"
          },
          "meta": {
            "$ref": "#/components/schemas/responseMeta"
          }
        }
      },
      "effortLogQuery": {
        "type": "object",
        "properties": {
          "dateFrom": {
            "type": "string"
          },
          "dateTo": {
            "type": "string"
          },
          "usernames": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "areas": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "workItemIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            }
          },
          "activityTypes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "projects": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "notes": {
            "type": "string"
          },
          "page": {
            "type": "integer",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "format": "int32"
          },
          "sortBy": {
            "type": "string"
          },
          "sortDesc": {
            "type": "boolean"
          }
        }
      },
      "paginationInfo": {
        "type": "object",
        "properties": {
          "page": {
            "type": "integer",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "format": "int32"
          },
          "totalCount": {
            "type": "integer",
            "format": "int32"
          },
          "totalPages": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "responseMeta": {
        "type": "object",
        "properties": {
          "requestedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "statsSummary": {
        "type": "object",
        "properties": {
          "totalRecords": {
            "type": "integer",
            "format": "int32"
          },
          "totalHours": {
            "type": "number",
            "format": "double"
          },
          "userCount": {
            "type": "integer",
            "format": "int32"
          },
          "projectCount": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "statsSummaryResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/statsSummary"
          },
          "meta": {
            "$ref": "#/components/schemas/responseMeta"
          }
        }
      },
      "userLogCount": {
        "type": "object",
        "properties": {
          "user": {
            "type": "string"
          },
          "count": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "userLogCountListResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/userLogCount"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/responseMeta"
          }
        }
      }
    },
    "securitySchemes": {
      "bearer_auth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "token"
      }
    }
  }
}