{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "TypingDNA Auth API",
    "description": "Typing Biometrics Authentication API. It's FREE for testing and non-commercial.\n\nThe server is running fully on Microsoft Azure. To download the SDK, and generate your credentials go [here](https://typingdna.com/clients). \n\n**Userkey and Password**\n* Userkey: `your userkey`\n* Password: `your pass`\n"
  },
  "host": "typingdna-api.azurewebsites.net",
  "schemes": [
    "https"
  ],
  "securityDefinitions": {
    "basicAuth": {
      "type": "basic",
      "description": "HTTP Basic Authentication. Works over `HTTPS`"
    }
  },
  "paths": {
    "/api/save": {
      "post": {
        "security": [
          {
            "basicAuth": []
          }
        ],
        "description": "Saves a new typing pattern in the data base.",
        "parameters": [
          {
            "name": "userid",
            "in": "query",
            "description": "An id of the owner of a typing pattern.",
            "required": true,
            "type": "string"
          },
          {
            "name": "tp",
            "in": "query",
            "description": "A typing pattern.",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns 1 for success or 0 if it fails.",
            "schema": {
              "$ref": "#/definitions/SaveResults"
            }
          },
          "500": {
            "description": "Error"
          }
        }
      }
    },
    "/api/verify": {
      "post": {
        "security": [
          {
            "basicAuth": []
          }
        ],
        "description": "Compares a new typing pattern agains previous recorded ones for that particular user. The higher the quality the more accurate the matching. We recommend using quality=2 (standard).",
        "parameters": [
          {
            "name": "userid",
            "in": "query",
            "description": "An id of the owner of a typing pattern.",
            "required": true,
            "type": "string"
          },
          {
            "name": "tp",
            "in": "query",
            "description": "A typing pattern.",
            "required": true,
            "type": "string"
          },
          {
            "name": "quality",
            "in": "query",
            "description": "An integer  1 (lowest), 2 (standard), 3 (high), or 4 (highest)",
            "required": false,
            "type": "integer"
          },
          {
            "name": "enroll",
            "in": "query",
            "description": "An integer  0 or 1, to enroll if very good match is found choose 1",
            "required": false,
            "type": "integer"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the result parameter (between 0 - 1)",
            "schema": {
              "$ref": "#/definitions/VerifyResults"
            }
          },
          "500": {
            "description": "Error"
          }
        }
      }
    },
    "/api/checkuser": {
      "post": {
        "security": [
          {
            "basicAuth": []
          }
        ],
        "description": "Checks how many typing patterns were previously recorded for a certain user and returns that number.",
        "parameters": [
          {
            "name": "userid",
            "in": "query",
            "description": "An id of the owner of various typing patterns.",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the count (number of patterns) recorded for that particular user.",
            "schema": {
              "$ref": "#/definitions/CheckUserResults"
            }
          },
          "500": {
            "description": "Error"
          }
        }
      }
    },
    "/api/deleteuser": {
      "post": {
        "security": [
          {
            "basicAuth": []
          }
        ],
        "description": "Removes all typing patterns belonging to a certain user.",
        "parameters": [
          {
            "name": "userid",
            "in": "query",
            "description": "An id of the owner of various typing patterns.",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the deleted number of patterns for that particular user.",
            "schema": {
              "$ref": "#/definitions/DeleteUserResults"
            }
          },
          "500": {
            "description": "Error"
          }
        }
      }
    },
    "/api/match": {
      "post": {
        "security": [
          {
            "basicAuth": []
          }
        ],
        "description": "You can match any two typing patterns agains each other and see if they belong to the same person. A matching score/result will be returned further. We do not recommend using this method. Try using the save + verify methods, so that you don't have to store typing patterns yourself.\n\nHowever, if you do store typing patterns, make sure you encrypt them and the link from/to whom they belong.",
        "parameters": [
          {
            "name": "tp1",
            "in": "query",
            "description": "A first typing pattern.",
            "required": true,
            "type": "string"
          },
          {
            "name": "tp2",
            "in": "query",
            "description": "A second typing pattern.",
            "required": true,
            "type": "string"
          },
          {
            "name": "quality",
            "in": "query",
            "description": "An integer  1 (lowest), 2 (standard), 3 (high), or 4 (highest)",
            "required": false,
            "type": "integer"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the result parameter (between 0 - 1)",
            "schema": {
              "$ref": "#/definitions/MatchResults"
            }
          },
          "500": {
            "description": "Error"
          }
        }
      }
    }
  },
  "definitions": {
    "SaveResults": {
      "properties": {
        "message": {
          "type": "string"
        },
        "success": {
          "type": "boolean"
        }
      }
    },
    "CheckUserResults": {
      "properties": {
        "message": {
          "type": "string"
        },
        "success": {
          "type": "boolean"
        },
        "count": {
          "type": "integer"
        }
      }
    },
    "DeleteUserResults": {
      "properties": {
        "message": {
          "type": "string"
        },
        "success": {
          "type": "boolean"
        },
        "deleted": {
          "type": "integer"
        }
      }
    },
    "VerifyResults": {
      "properties": {
        "message": {
          "type": "string"
        },
        "success": {
          "type": "boolean"
        },
        "result": {
          "type": "number"
        }
      }
    },
    "MatchResults": {
      "properties": {
        "message": {
          "type": "string"
        },
        "success": {
          "type": "boolean"
        },
        "result": {
          "type": "number"
        }
      }
    }
  }
}
