{
  "openapi": "3.1.0",
  "info": {
    "title": "Graph Paper plot link service",
    "version": "1.0.0",
    "description": "Check a Graph Paper plot document and get the link that opens it as an editable draft. No account and no API key. The same check is the tool make_plot_link of the MCP server https://graph-paper.io/mcp (Streamable HTTP, no authentication). Instructions for programs: https://graph-paper.io/for-agents/en/"
  },
  "externalDocs": {
    "description": "The plot document format: every field, the series types, the limits and complete examples.",
    "url": "https://graph-paper.io/plot-document-format/en/"
  },
  "servers": [
    {
      "url": "https://graph-paper.io"
    }
  ],
  "paths": {
    "/plot-link": {
      "post": {
        "operationId": "makePlotLink",
        "summary": "Check a plot document and get its link",
        "requestBody": {
          "required": true,
          "description": "The plot document, as a JSON object with at least \"title\" and \"series\". The format is at https://graph-paper.io/plot-document-format/en/.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title",
                  "series"
                ],
                "externalDocs": {
                  "url": "https://graph-paper.io/plot-document-format/en/"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The document is valid: ok is true, and url is the link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlotLinkAnswer"
                }
              }
            }
          },
          "400": {
            "description": "The body is not JSON, is not UTF-8, or is empty.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlotLinkAnswer"
                }
              }
            }
          },
          "413": {
            "description": "The document is larger than 65,536 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlotLinkAnswer"
                }
              }
            }
          },
          "422": {
            "description": "The JSON is not a valid plot document: errors lists each error with its path.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlotLinkAnswer"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "makePlotLinkFromQuery",
        "summary": "Check a plot document given in the query and get its link",
        "description": "For a program that can only fetch a URL. Every GET answers with status 200; the status field of the answer is the status that a POST of the same document gets. Write a space as %20 and a plus sign as %2B. A large document needs POST.",
        "parameters": [
          {
            "name": "doc",
            "in": "query",
            "required": false,
            "description": "The plot document as percent-encoded JSON. Without it, the answer has a usage text and an example URL. The format is at https://graph-paper.io/plot-document-format/en/.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Always 200. The status field is the status that a POST gets.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/PlotLinkAnswer"
                    },
                    {
                      "$ref": "#/components/schemas/GetFields"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PlotLinkAnswer": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "description": "True when the document is valid and url is given."
          },
          "url": {
            "type": "string",
            "description": "The link that opens the document."
          },
          "title": {
            "type": "string"
          },
          "dimension": {
            "type": "integer",
            "enum": [
              2,
              3
            ]
          },
          "category": {
            "type": "string",
            "enum": [
              "2d",
              "3d",
              "data"
            ]
          },
          "rows": {
            "type": "object",
            "description": "How many rows of each kind the document has.",
            "properties": {
              "series": {
                "type": "integer"
              },
              "variables": {
                "type": "integer"
              },
              "points": {
                "type": "integer"
              },
              "definitions": {
                "type": "integer"
              },
              "actions": {
                "type": "integer"
              },
              "markers": {
                "type": "integer"
              }
            }
          },
          "note": {
            "type": "string",
            "description": "With ok true: the formulas were not computed, and what to ask the person when a row does not work."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string",
                  "description": "The field, in JSON path notation such as \"series[0].fn\"; empty for the whole document."
                },
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "path",
                "message"
              ]
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string",
                  "description": "The field, in JSON path notation such as \"series[0].fn\"; empty for the whole document."
                },
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "path",
                "message"
              ]
            }
          }
        },
        "required": [
          "ok",
          "warnings"
        ]
      },
      "GetFields": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "enum": [
              200,
              400,
              413,
              422
            ],
            "description": "The status that a POST of the same document gets."
          },
          "usage": {
            "type": "string",
            "description": "Only when the GET has no doc: how to use the service."
          },
          "example": {
            "type": "string",
            "description": "Only when the GET has no doc: a complete, working GET URL."
          }
        },
        "required": [
          "status"
        ]
      }
    }
  }
}
