{
  "openapi": "3.0.1",
  "info": {
    "title": "APEye 1.0",
    "description": "Wildeye API for extracting time series information recorded by our Wildeyes.  The API supports multiple measurement types and sensors.",
    "contact": {
      "name": "Wildeye Support",
      "url": "https://www.mywildeye.com",
      "email": "support@mywildeye.com"
    },
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.mywildeye.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/v{version}/Categories": {
      "get": {
        "tags": [
          "Categories"
        ],
        "summary": "List of Categories available for the current user",
        "description": "Sample request:\r\n            \r\n    GET /api/v1/categories\r\n    \r\nSample response:\r\n\r\n    [\r\n    \t\"Flow Meter - Irrigation\",\r\n    \t\"Level - Other\",\r\n    \t\"Flow Meter - Other\",\r\n    \t\"Flow Meter - Water\"\r\n    ]",
        "parameters": [
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v{version}/Measurements": {
      "get": {
        "tags": [
          "Measurements"
        ],
        "summary": "Returns a list of Measurements",
        "description": "Sample request(s):\r\n            \r\n    Fetch all measurements for a specific measurement category, from a defined start date. Starting with first page of results.\r\n    GET /api/v1/measurements?query=categories=['Flow Meter - Irrigation']&start=2024-03-07&page=1\r\n    \r\n    Fetch all measurements for a specific input id.  Will default to from 1 day ago.\r\n    GET /api/v1/measurements?query=ids=['029c99f0-f53a-4e05-bb86-1db8dc19f634','b9c613cc-946a-4a52-866e-03bd660a1881','6d43525d-afff-4ed2-8564-60a24efb1f0b']\r\n    \r\n    Fetch all mesaurements for all inputs connected to a list of specified devices.\r\n    GET /api/v1/measurements?query=deviceids=['op74525','op70449']\r\n\r\nSample response:\r\n\r\n    [\r\n    \t{\r\n    \t\t\"id\": \"d18bca39-4ff9-40e8-8596-2b690a55b064\",\r\n    \t\t\"measurements\": [\r\n    \t\t\t{\r\n    \t\t\t\t\"time\": \"2024-03-07T04:31:00\",\r\n    \t\t\t\t\"value\": -10.4368385486663\r\n    \r\n                },\r\n    \t\t\t{\r\n    \t\t\t\t\"time\": \"2024-03-07T04:32:00\",\r\n    \t\t\t\t\"value\": -10.4366682034269\r\n    \t\t\t},\r\n    \t\t\t{\r\n                    \"time\": \"2024-03-07T04:33:00\",\r\n    \t\t\t\t\"value\": -10.4364978581875\r\n    \r\n                }\r\n             ]\r\n        }\r\n    ]",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number (start at 1 and increment page until an empty array is returned)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "query",
            "in": "query",
            "description": "Query string",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "start",
            "in": "query",
            "description": "Start date and time (If not supplied it will default to 1 day ago).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "end",
            "in": "query",
            "description": "End date",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/InputMeasurements"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v{version}/Measurements/latest": {
      "get": {
        "tags": [
          "Measurements"
        ],
        "summary": "Returns the latest measurements for the specified inputs.",
        "description": "Sample request:\r\n            \r\n    Fetch the latest measurements for a specific input id.\r\n    GET /api/v1/measurements/latest?query=ids=\\['029c99f0-f53a-4e05-bb86-1db8dc19f634'\\]&page=1\r\n            \r\nSample response:\r\n            \r\n    \\[\r\n    \t{\r\n    \t\t\"id\": \"029c99f0-f53a-4e05-bb86-1db8dc19f634\",\r\n    \t\t\"measurements\": [\r\n    \t\t\t{\r\n    \t\t\t\t\"time\": \"2024-03-07T04:31:00\",\r\n    \t\t\t\t\"value\": -10.4368385486663\r\n                }\r\n             ]\r\n        }\r\n    \\]",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number (start at 1 and increment page until an empty array is returned)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "query",
            "in": "query",
            "description": "Query string",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "count",
            "in": "query",
            "description": "Optional Count of Measurements to be returned",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/InputMeasurements"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v{version}/Ping": {
      "get": {
        "tags": [
          "Ping"
        ],
        "summary": "Used to determine that the service is alive and responding.",
        "parameters": [
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/v{version}/Ping/auth": {
      "get": {
        "tags": [
          "Ping"
        ],
        "summary": "Used to determine the authentication header is correct and you are authenticated",
        "parameters": [
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/v{version}/Sites": {
      "get": {
        "tags": [
          "Sites"
        ],
        "summary": "List of Sites and Inputs",
        "description": "Sample request:\r\n            \r\n    GET /api/v1/sites\r\n    \r\nSample response:\r\n\r\n    [\r\n    \t{\r\n    \t\t\"id\": \"81df4df6-b270-451c-9158-46b9f4d3e405\",\r\n    \t\t\"name\": \"Test Logger\",\r\n    \t\t\"projectReference\": null,\r\n    \t\t\"deviceId\": \"op69417\",\r\n    \t\t\"gps\": null,\r\n    \t\t\"client\": {\r\n    \t\t\t\"id\": \"c0be8a4f-0a49-4701-aa93-8285698717c8\",\r\n    \t\t\t\"name\": \"Staff\"\r\n    \t\t},\r\n    \t\t\"inputs\": [\r\n    \t\t\t{\r\n    \t\t\t\t\"id\": \"609e4580-ed91-435c-aacf-dc689700c497\",\r\n    \t\t\t\t\"name\": \"Level\",\r\n    \t\t\t\t\"logical\": \"\",\r\n    \t\t\t\t\"scada\": null,\r\n    \t\t\t\t\"loggingInterval\": 300,\r\n    \t\t\t\t\"unit\": \"meter\",\r\n    \t\t\t\t\"category\": \"Level - Other\",\r\n    \t\t\t\t\"sensor\": \"Water level\",\r\n    \t\t\t\t\"sensorType\": \"ACC-SEN-SUBM-ABS-S3-D5M-CxxM EasyLevel sensor\"\r\n    \r\n                },\r\n    \t\t\t{\r\n    \t\t\t\t\"id\": \"79bbe4fe-381e-41a2-a4ac-0859d2f24938\",\r\n    \t\t\t\t\"name\": \"Barometric pressure\",\r\n    \t\t\t\t\"logical\": \"\",\r\n    \t\t\t\t\"scada\": null,\r\n    \t\t\t\t\"loggingInterval\": 300,\r\n    \t\t\t\t\"unit\": \"hectopascal\",\r\n    \t\t\t\t\"category\": \"Pressure - Air\",\r\n    \t\t\t\t\"sensor\": \"Water level\",\r\n    \t\t\t\t\"sensorType\": \"ACC-SEN-SUBM-ABS-S3-D5M-CxxM EasyLevel sensor\"\r\n    \t\t\t}\r\n    \t\t]\r\n    \t}\r\n    ]",
        "parameters": [
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the available list of <see cref=\"T:System.Collections.Generic.IEnumerable`1\">Sites</see> and <see cref=\"T:ApEye.Model.Input\">Inputs</see> for each <see cref=\"T:ApEye.Model.Site\">site</see>.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Site"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Client": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Id of Client",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "Name of Client",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Wildeye's Client details"
      },
      "Gps": {
        "type": "object",
        "properties": {
          "latitude": {
            "type": "number",
            "description": "Latitude",
            "format": "double"
          },
          "longitude": {
            "type": "number",
            "description": "Longitude",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Global Positioning System co-ordinates for the site of the Wildeye."
      },
      "Input": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Id of Input",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "Name of Input",
            "nullable": true
          },
          "logical": {
            "type": "string",
            "description": "Logical Name of Input",
            "nullable": true
          },
          "scada": {
            "type": "string",
            "description": "Scada ID Tag for Input",
            "nullable": true
          },
          "loggingInterval": {
            "type": "number",
            "description": "Logging interval of input in seconds",
            "format": "double"
          },
          "unit": {
            "type": "string",
            "description": "Unit of measurement",
            "nullable": true
          },
          "category": {
            "type": "string",
            "description": "Category of measurement",
            "nullable": true
          },
          "sensor": {
            "type": "string",
            "description": "Sensor name for Input",
            "nullable": true
          },
          "sensorType": {
            "type": "string",
            "description": "Sensor type for Input",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "An Input holds the time series data for a particular measurement at a site."
      },
      "InputMeasurements": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "measurements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Measurement"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Measurement": {
        "type": "object",
        "properties": {
          "time": {
            "type": "string",
            "description": "Date and time of reading",
            "format": "date-time"
          },
          "value": {
            "type": "number",
            "description": "Reading value",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "description": "Measurement at a particular time"
      },
      "Site": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Id of Site",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "Name of Site",
            "nullable": true
          },
          "projectReference": {
            "type": "string",
            "description": "Project Reference of Site",
            "nullable": true
          },
          "lastUpload": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "deviceId": {
            "type": "string",
            "description": "OP Number of the Site",
            "nullable": true
          },
          "gps": {
            "$ref": "#/components/schemas/Gps"
          },
          "displayTimezone": {
            "$ref": "#/components/schemas/TimeZone"
          },
          "client": {
            "$ref": "#/components/schemas/Client"
          },
          "inputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Input"
            },
            "description": "List of Inputs available for this Site",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Site details"
      },
      "TimeZone": {
        "type": "object",
        "properties": {
          "offset": {
            "type": "string",
            "description": "Offset of the timezone",
            "nullable": true
          },
          "followsDST": {
            "type": "boolean",
            "description": "Does the timezone follow Daylight Saving Time"
          }
        },
        "additionalProperties": false,
        "description": "Timezone details"
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "apiKey",
        "description": "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
        "name": "Authorization",
        "in": "header"
      }
    }
  },
  "tags": [
    {
      "name": "Categories",
      "description": "Returns a list of Categories"
    },
    {
      "name": "Measurements",
      "description": "Returns a list of Measurements"
    },
    {
      "name": "Ping",
      "description": "The Ping endpoint is for seeing if the server is alive and whether you can authenticate with it"
    },
    {
      "name": "Sites",
      "description": "Returns a list of Sites and Inputs"
    }
  ]
}