{
  "$defs": {
    "ActAnswer": {
      "description": "`{\"action\": …, \"ids\": […]}`: what was done, and what was skipped and why.",
      "properties": {
        "done": {
          "items": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "type": "array"
        },
        "skipped": {
          "items": {
            "$ref": "#/$defs/Skipped"
          },
          "type": "array"
        }
      },
      "required": [
        "done",
        "skipped"
      ],
      "type": "object"
    },
    "AddAnswer": {
      "description": "An address added (`url`): the download's id, or `pending` while a torrent's files are looked\nup (it joins the list once they are known).",
      "properties": {
        "id": {
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "pending": {
          "default": false,
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "ApiAnswer": {
      "description": "`{\"api\": true}` / `{\"api\": false}`: the API's new state.",
      "properties": {
        "api": {
          "type": "boolean"
        }
      },
      "required": [
        "api"
      ],
      "type": "object"
    },
    "BrowserCookie": {
      "description": "One cookie as the browser keeps it (`cookies.getAll`'s fields, under the extension's names\ntoo: `hostOnly`, `expirationDate`).",
      "properties": {
        "domain": {
          "default": "",
          "description": "`.youtube.com` (sent to its subdomains too) or a host name.",
          "type": "string"
        },
        "expires": {
          "default": null,
          "description": "When it expires, in seconds since 1970; none: when the browser closes.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "host_only": {
          "default": false,
          "description": "Sent to `domain` itself only, never its subdomains.",
          "type": "boolean"
        },
        "name": {
          "default": "",
          "type": "string"
        },
        "path": {
          "default": "",
          "type": "string"
        },
        "secure": {
          "default": false,
          "description": "Sent over HTTPS only.",
          "type": "boolean"
        },
        "value": {
          "default": "",
          "type": "string"
        }
      },
      "type": "object"
    },
    "CategoryInfo": {
      "description": "One category of the list.",
      "properties": {
        "key": {
          "description": "What `category` takes and a download's `category` says (a built-in category's English\nname, as shipped).",
          "type": "string"
        },
        "name": {
          "description": "Its name as the user sees it: a built-in one's English name (translated where it is\nshown) unless the user renamed it.",
          "type": "string"
        }
      },
      "required": [
        "key",
        "name"
      ],
      "type": "object"
    },
    "DownloadInfo": {
      "description": "One download of the list.",
      "properties": {
        "added": {
          "description": "When it was added, as the list shows it; null for downloads from before that column.",
          "type": [
            "string",
            "null"
          ]
        },
        "category": {
          "default": "",
          "description": "Its category's `key` (see [`CategoryInfo`]).",
          "type": "string"
        },
        "downloaded": {
          "description": "Bytes downloaded so far.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "error": {
          "description": "Why it failed, for a download in `Error`.",
          "type": [
            "string",
            "null"
          ]
        },
        "file": {
          "description": "The file's name.",
          "type": "string"
        },
        "id": {
          "description": "What the actions take (`ids`); never reused.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "path": {
          "description": "Where it is saved: the file, or a torrent's folder.",
          "type": "string"
        },
        "size": {
          "description": "Its size in bytes; null while unknown.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "speed": {
          "description": "Bytes per second; 0 when it isn't running.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "status": {
          "description": "`Queued` (added, never started), `Downloading`, `Stopped`, `Complete` or `Error`.",
          "type": "string"
        },
        "url": {
          "description": "Its address (a video's page, a torrent's magnet link).",
          "type": "string"
        }
      },
      "required": [
        "id",
        "file",
        "url",
        "path",
        "status",
        "downloaded",
        "speed"
      ],
      "type": "object"
    },
    "ErrorAnswer": {
      "description": "An unknown question or action, or a question while the API is off.",
      "properties": {
        "code": {
          "description": "For programs: `\"api-off\"` while the API is off.",
          "type": [
            "string",
            "null"
          ]
        },
        "error": {
          "description": "For people; its wording may change.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object"
    },
    "ListAnswer": {
      "description": "`{\"query\": \"list\"}`: every download, and the total speed.",
      "properties": {
        "categories": {
          "default": [],
          "description": "The categories a new download can go to (General first).",
          "items": {
            "$ref": "#/$defs/CategoryInfo"
          },
          "type": "array"
        },
        "downloads": {
          "items": {
            "$ref": "#/$defs/DownloadInfo"
          },
          "type": "array"
        },
        "free": {
          "default": null,
          "description": "Free space where downloads go (the General category's folder), bytes; null when unknown.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "queues": {
          "default": [],
          "description": "The queues, in the Scheduler's order (the first is the main queue).",
          "items": {
            "$ref": "#/$defs/QueueInfo"
          },
          "type": "array"
        },
        "speed": {
          "description": "The total download speed, bytes per second.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "downloads",
        "speed"
      ],
      "type": "object"
    },
    "PairAnswer": {
      "description": "`{\"pair\": true}` (#157): a new pairing code for the remote control, while it is on.",
      "properties": {
        "code": {
          "description": "The 8-digit code; it works once, for `minutes`.",
          "type": "string"
        },
        "minutes": {
          "format": "uint32",
          "minimum": 0,
          "type": "integer"
        },
        "qr": {
          "description": "A QR code of the first address with the code, drawn with text blocks for a terminal.",
          "type": "string"
        },
        "urls": {
          "description": "The page's addresses, the one a phone most likely reaches first.",
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "required": [
        "code",
        "minutes",
        "urls",
        "qr"
      ],
      "type": "object"
    },
    "QueueInfo": {
      "description": "One queue of the list.",
      "properties": {
        "ids": {
          "description": "Its downloads' ids, in its order.",
          "items": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "type": "array"
        },
        "name": {
          "description": "Its name: what `queue` takes (a built-in queue's in English, as shipped).",
          "type": "string"
        },
        "running": {
          "description": "Is it running?",
          "type": "boolean"
        }
      },
      "required": [
        "name",
        "running",
        "ids"
      ],
      "type": "object"
    },
    "Request": {
      "description": "One request line: the token from ipc.json and the command's fields.",
      "properties": {
        "action": {
          "default": null,
          "description": "Automation API: `\"pause\"`, `\"start\"`, `\"remove\"` (off the list, its file kept) or\n`\"delete\"` (with its file) the downloads `ids`; answered with what was done and skipped.\n`\"start_queue\"` / `\"stop_queue\"` start or stop the queue named `queue`.",
          "type": [
            "string",
            "null"
          ]
        },
        "api": {
          "default": null,
          "description": "Automation API: turn it on or off.",
          "type": [
            "boolean",
            "null"
          ]
        },
        "category": {
          "default": null,
          "description": "A category for `url` (its `key` in the list's `categories`); none: by the file's type.",
          "type": [
            "string",
            "null"
          ]
        },
        "cookie_jar": {
          "description": "From the browser: the same cookies, each with the domain, path and flags the browser\nkeeps for it, for yt-dlp's cookie file. yt-dlp may ask another host than the page's (a\nYouTube Music page is looked up on www.youtube.com), and a cookie of `.youtube.com` goes\nthere too. An older extension sends `cookies` only.",
          "items": {
            "$ref": "#/$defs/BrowserCookie"
          },
          "type": "array"
        },
        "cookies": {
          "default": null,
          "type": [
            "string",
            "null"
          ]
        },
        "dir": {
          "default": null,
          "description": "Save folder (`/p`) and file name (`/f`).",
          "type": [
            "string",
            "null"
          ]
        },
        "exclude_site": {
          "default": null,
          "description": "From the browser's toolbar button: leave this site's downloads (a host name) to the\nbrowser from now on (Options → File types → excluded sites).",
          "type": [
            "string",
            "null"
          ]
        },
        "exit": {
          "default": false,
          "description": "`/exit` (beyond IDM): the running app saves and quits (the installer, before an upgrade\nor an uninstall). Starts nothing when no app runs.",
          "type": "boolean"
        },
        "final_url": {
          "default": null,
          "description": "From the browser: where its redirects from `url` ended (`url` stays the address asked\nfor, so an expired signed link can be renewed from it).",
          "type": [
            "string",
            "null"
          ]
        },
        "ids": {
          "default": [],
          "items": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "type": "array"
        },
        "later": {
          "default": false,
          "description": "`/a`: add to the main queue, don't start.",
          "type": "boolean"
        },
        "links": {
          "default": [],
          "description": "From the browser's right-click menu: the links of a page or a selection, offered in the\nlist window to pick from (the browser's `referer` and `cookies` go with them).",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "mime": {
          "default": null,
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "default": null,
          "type": [
            "string",
            "null"
          ]
        },
        "pair": {
          "default": false,
          "description": "The remote control (#157, `misterdownloadmanager-cli pair`): show a new pairing code;\nanswered with it, the page's addresses and a QR code to scan ([`api::PairAnswer`]).",
          "type": "boolean"
        },
        "panel_hide_site": {
          "default": null,
          "description": "From that button's menu: never show it on this site (a host name) again.",
          "type": [
            "string",
            "null"
          ]
        },
        "post": {
          "default": null,
          "description": "From the browser: a form's download, re-sent as a POST with this body and its\nContent-Type (`post_type`).",
          "type": [
            "string",
            "null"
          ]
        },
        "post_type": {
          "default": null,
          "type": [
            "string",
            "null"
          ]
        },
        "private": {
          "default": false,
          "description": "From a private (incognito) window: the download is never written to the saved list.",
          "type": "boolean"
        },
        "proxy": {
          "default": null,
          "description": "From the browser (#42): the proxy it uses for this address (\"http://host:port\",\n\"https://…\", \"socks5h://…\", \"socks4://…\"), set by a VPN or proxy extension or its\nsettings; or its proxy auto-config script's text. The app downloads through the same\none (Options → Proxy / Socks → \"Use proxy/socks from a browser's request\").",
          "type": [
            "string",
            "null"
          ]
        },
        "proxy_login": {
          "default": false,
          "description": "That proxy asked the browser for a login, which the extension that set it answers with\nits own: no other program can have it.",
          "type": "boolean"
        },
        "proxy_pac": {
          "default": null,
          "type": [
            "string",
            "null"
          ]
        },
        "query": {
          "default": null,
          "description": "Automation API (off by default, beyond IDM): `\"list\"` asks for every download as JSON.",
          "type": [
            "string",
            "null"
          ]
        },
        "queue": {
          "default": null,
          "description": "A queue by name: where `url` waits (with `later`), or the one `action` starts or stops.",
          "type": [
            "string",
            "null"
          ]
        },
        "referer": {
          "default": null,
          "description": "From the browser: request context to reuse.",
          "type": [
            "string",
            "null"
          ]
        },
        "show": {
          "default": null,
          "description": "`/show <window>` (beyond IDM): the running app opens one of its windows by name, for\nscreenshots and scripted checks (tools/lab/docs-shots.ps1): `addurl`, `batch`, `find`,\n`scheduler`, `about`, `language`, `shortcuts`, `speedlimit`, `properties`, `delete`,\n`progress`, `existing-files`, `video-page`, `video-helpers`, `video-subs`,\n`torrent-settings`, `add-trackers`, `menu` (the first download's right-click menu),\n`options[:general|types|saveto|downloads|connection|proxy|logins|sounds|regional|panels]`.",
          "type": [
            "string",
            "null"
          ]
        },
        "silent": {
          "default": false,
          "description": "`/n`: silent — no Download File Info dialog.",
          "type": "boolean"
        },
        "size": {
          "default": null,
          "description": "From the browser: the size and type its own download had (no need to look them up).",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "start_queue": {
          "default": false,
          "description": "`/s`: start the main queue.",
          "type": "boolean"
        },
        "startup": {
          "default": false,
          "description": "`/startup` (beyond IDM): started with the session (Options → General → Launch on\nstartup, or the installer's \"Start when Windows starts\", #226): GDM starts in the\nnotification area, its window hidden. Changes nothing in a running app.",
          "type": "boolean"
        },
        "token": {
          "description": "The `token` from ipc.json (it changes at every start of the app).",
          "type": "string"
        },
        "url": {
          "default": null,
          "description": "The URL to download (`/d`).",
          "type": [
            "string",
            "null"
          ]
        },
        "user_agent": {
          "default": null,
          "type": [
            "string",
            "null"
          ]
        },
        "video_page": {
          "default": null,
          "description": "From the browser's download button over a video: open the Download video window for this\npage (its address; an embedded player's own).",
          "type": [
            "string",
            "null"
          ]
        },
        "video_title": {
          "default": null,
          "description": "The title of the page the button was clicked on: a video yt-dlp knows only by its address\nis named by it.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "token"
      ],
      "type": "object"
    },
    "Skipped": {
      "properties": {
        "id": {
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "why": {
          "description": "\"no such download\", \"not running\", \"already running\", \"complete\" or \"running: pause it\nfirst\".",
          "type": "string"
        }
      },
      "required": [
        "id",
        "why"
      ],
      "type": "object"
    }
  },
  "$id": "https://misterdownloadmanager.com/automation-api.schema.json",
  "$ref": "#/$defs/Request",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "One JSON line to the port in ipc.json (on 127.0.0.1), one line back. A request is `Request`. A command (an address to add, start_queue) is answered `ok`; a question is answered with the JSON object for it (`ListAnswer`, `ActAnswer`, `ApiAnswer`) or an `ErrorAnswer`. A wrong token is answered `denied`, an app that doesn't answer within 2 seconds `timeout`. Guide: https://misterdownloadmanager.com/help/command-line.html#the-automation-api",
  "title": "GolinksPRO Download Manager automation API"
}
