{
  "openapi": "3.1.1",
  "info": {
    "title": "CiteShape API",
    "version": "1.0.0",
    "summary": "Paste a DOI, ORCID iD, ISBN or arXiv ID: validated, resolved, and formatted as APA, BibTeX and RIS.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://citeshape.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Paste a DOI, ORCID iD, ISBN or arXiv ID: validated, resolved, and formatted as APA, BibTeX and RIS.",
        "description": "CiteShape finds the identifier in whatever you paste (URL, \"doi:\", reference text), normalises it, validates check digits (ORCID ISO 7064, ISBN-10/13), resolves authoritative metadata from Crossref, ORCID and arXiv, and emits APA-style, BibTeX and RIS citations. Retrieved facts are kept separate from your input, and nothing missing is guessed.\n\nMethodology:\n- Detection order: DOI (10.prefix/suffix, also in doi.org URLs) → ORCID iD → arXiv ID → ISBN. DOIs are lower-cased (DOIs are case-insensitive).\n- ORCID: ISO 7064 MOD 11-2 check digit. ISBN-10: weighted sum mod 11; ISBN-13: alternating 1/3 weights mod 10. ISBN-10 is converted to ISBN-13 with prefix 978.\n- Resolution: DOI → api.crossref.org/works/{doi}; ORCID → pub.orcid.org/v3.0/{id}/record (JSON); arXiv → export.arxiv.org/api/query. ISBN metadata is not resolved (no open authoritative registry).\n- Citations are generated only from retrieved metadata; APA output follows APA 7 reference structure for author list, year, title, container, volume(issue), pages and DOI link.",
        "tags": [
          "developer"
        ],
        "x-mcp-tool": "citeshape",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CiteshapeInput"
              },
              "examples": {
                "example1": {
                  "summary": "ORCID check digit (offline)",
                  "value": {
                    "identifier": "https://orcid.org/0000-0002-1825-0097",
                    "resolve": false
                  }
                },
                "example2": {
                  "summary": "ISBN-10 → ISBN-13 (offline)",
                  "value": {
                    "identifier": "ISBN 0-306-40615-2",
                    "resolve": false
                  }
                },
                "example3": {
                  "summary": "Invalid ORCID (offline)",
                  "value": {
                    "identifier": "0000-0002-1825-0098",
                    "resolve": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CiteshapeResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "CiteshapeInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "identifier": {
            "title": "DOI, ORCID iD, ISBN or arXiv ID",
            "type": "string",
            "maxLength": 500
          },
          "resolve": {
            "title": "Look up metadata online (Crossref / ORCID / arXiv)",
            "type": "boolean",
            "default": true
          }
        },
        "required": [
          "identifier"
        ]
      },
      "CiteshapeResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind",
              "id",
              "valid",
              "problem",
              "canonicalUrl",
              "resolved",
              "resolver",
              "work",
              "person",
              "citations"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "doi",
                  "orcid",
                  "isbn",
                  "arxiv"
                ]
              },
              "id": {
                "type": "string"
              },
              "valid": {
                "type": "boolean"
              },
              "problem": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "canonicalUrl": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "resolved": {
                "type": "boolean"
              },
              "resolver": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "work": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "type",
                  "title",
                  "authors",
                  "container",
                  "publisher",
                  "year",
                  "month",
                  "day",
                  "volume",
                  "issue",
                  "pages",
                  "doi",
                  "url"
                ],
                "properties": {
                  "type": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "authors": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "given",
                        "family",
                        "orcid"
                      ],
                      "properties": {
                        "given": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "family": {
                          "type": "string"
                        },
                        "orcid": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      }
                    }
                  },
                  "container": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "publisher": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "year": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "month": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "day": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "volume": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "issue": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "pages": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "doi": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "url": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "person": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "name",
                  "works"
                ],
                "properties": {
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "works": {
                    "type": "integer"
                  }
                }
              },
              "citations": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "apa",
                  "bibtex",
                  "ris"
                ],
                "properties": {
                  "apa": {
                    "type": "string"
                  },
                  "bibtex": {
                    "type": "string"
                  },
                  "ris": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}