{
  "openapi": "3.1.0",
  "info": {
    "title": "Polyzon API",
    "version": "1.0.0",
    "description": "搜索Polyzon目录中的3D模型，获取模型卡片。需使用在polyzon.org/account/apps创建的个人令牌访问。"
  },
  "servers": [
    {
      "url": "https://api.polyzon.org"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "以pzk_…开头的个人令牌，可在polyzon.org/account/apps的“应用与API”页面获取。"
      }
    }
  },
  "paths": {
    "/v1/search": {
      "get": {
        "operationId": "search",
        "summary": "搜索模型",
        "description": "搜索Polyzon目录：涵盖所有平台的模型，支持筛选和分页。最多可获取前2400个结果（page × size）。",
        "x-daily-quota": true,
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "搜索词，仅支持俄语或英语，最多200个字符。",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "example": "dragon"
          },
          {
            "name": "page",
            "in": "query",
            "description": "页码，从1开始。",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 1
            }
          },
          {
            "name": "size",
            "in": "query",
            "description": "每页模型数。page × size不得超过2400。",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "排序方式：relevant（按相关度）、popular（按模型在所属平台上的热度）、newest（最新优先）、likes、makes、downloads。",
            "schema": {
              "type": "string",
              "enum": [
                "relevant",
                "popular",
                "newest",
                "likes",
                "makes",
                "downloads"
              ],
              "default": "relevant"
            }
          },
          {
            "name": "free",
            "in": "query",
            "description": "仅返回免费模型。",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          },
          {
            "name": "sources",
            "in": "query",
            "description": "来源平台，多个值以英文逗号分隔：thingiverse, cults3d, printables, makerworld, 3dtoday, crealitycloud, myminifactory, thangs, youmagine, grabcad, sketchfab, threeding, nexprint, nasa, nih3d, smithsonian, pinshape, cgtrader, gambody, jewelmodel, makeronline, 3dexport。",
            "schema": {
              "type": "string"
            },
            "example": "thingiverse,printables"
          },
          {
            "name": "formats",
            "in": "query",
            "description": "文件格式，多个值以英文逗号分隔：stl、3mf、obj、step、scad、gcode等。",
            "schema": {
              "type": "string"
            },
            "example": "stl,3mf"
          },
          {
            "name": "license",
            "in": "query",
            "description": "许可协议，多个值以英文逗号分隔：cc0, cc-by, cc-by-sa, cc-by-nd, cc-by-nc, cc-by-nc-sa, cc-by-nc-nd, gpl, lgpl, mit, bsd, private-use, commercial, custom, unknown。",
            "schema": {
              "type": "string"
            },
            "example": "cc0,cc-by"
          },
          {
            "name": "lang",
            "in": "query",
            "description": "标题和标签的语言：ru或en。原文为其他语言时，返回机器翻译。",
            "schema": {
              "type": "string",
              "enum": [
                "ru",
                "en"
              ],
              "default": "ru"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "一页搜索结果。`hasMore`表示在前2400个结果范围内是否还有下一页；`partial`表示部分目录未响应，结果不完整。`stats.collects`为被收藏到合集的次数；若平台不统计收藏，则为下载次数。",
            "content": {
              "application/json": {
                "example": {
                  "query": "dragon",
                  "correctedQuery": null,
                  "didYouMean": null,
                  "total": 1873,
                  "totalRelation": "eq",
                  "page": 1,
                  "size": 20,
                  "hasMore": true,
                  "partial": false,
                  "items": [
                    {
                      "source": "thingiverse",
                      "id": "tv-1234567",
                      "title": "Articulated dragon (example)",
                      "url": "https://www.thingiverse.com/thing:1234567",
                      "thumbnail": "https://cdn.thingiverse.com/assets/dragon.jpg",
                      "creator": "example_maker",
                      "license": "cc-by-nc",
                      "price": {
                        "type": "free",
                        "value": 0,
                        "currency": null,
                        "display": "Free"
                      },
                      "formats": [
                        "stl"
                      ],
                      "tags": [
                        "dragon",
                        "toy"
                      ],
                      "stats": {
                        "likes": 51234,
                        "comments": 870,
                        "makes": 3120,
                        "collects": 61000
                      },
                      "publishedAt": "2021-01-17T10:21:00Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效（`bad_request`，`param`字段会指明是哪一个），或分页过深（`page_too_deep`）。"
          },
          "401": {
            "description": "未提供令牌（`unauthorized`），或令牌无效、已被撤销（`invalid_token`）。"
          },
          "403": {
            "description": "令牌所有者尚未接受Polyzon的最新条款（`account_action_required`），请登录账号处理；或者该IP地址今天已有其他账号在使用（`too_many_accounts`）。"
          },
          "429": {
            "description": "超出每分钟速率限制（`rate_limited`）、每日配额已用完（`quota_exceeded`），或IP地址的每日上限已用完（`address_quota_exceeded`）。请在`Retry-After`指定的秒数后重试。"
          },
          "503": {
            "description": "目录或令牌校验服务暂时不可用（`unavailable`）。请稍后重试。"
          }
        }
      }
    },
    "/v1/models/{source}/{id}": {
      "get": {
        "operationId": "getModel",
        "summary": "模型卡片",
        "description": "按平台和ID获取模型，二者的取值与搜索结果条目及模型页面地址polyzon.org/model/{source}/{id}中的一致。图片链接指向平台自己的CDN。",
        "x-daily-quota": true,
        "parameters": [
          {
            "name": "source",
            "in": "path",
            "required": true,
            "description": "模型的来源平台。",
            "schema": {
              "type": "string",
              "enum": [
                "thingiverse",
                "cults3d",
                "printables",
                "makerworld",
                "3dtoday",
                "crealitycloud",
                "myminifactory",
                "thangs",
                "youmagine",
                "grabcad",
                "sketchfab",
                "threeding",
                "nexprint",
                "nasa",
                "nih3d",
                "smithsonian",
                "pinshape",
                "cgtrader",
                "gambody",
                "jewelmodel",
                "makeronline",
                "3dexport"
              ]
            },
            "example": "thingiverse"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "模型在平台上的ID，带Polyzon前缀，例如tv-1234567。",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "tv-1234567"
          },
          {
            "name": "lang",
            "in": "query",
            "description": "标题、描述和标签的语言：ru或en。",
            "schema": {
              "type": "string",
              "enum": [
                "ru",
                "en"
              ],
              "default": "ru"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "模型数据。`copies`列出其他平台上的同一模型。",
            "content": {
              "application/json": {
                "example": {
                  "source": "thingiverse",
                  "id": "tv-1234567",
                  "title": "Articulated dragon (example)",
                  "url": "https://www.thingiverse.com/thing:1234567",
                  "thumbnail": "https://cdn.thingiverse.com/assets/dragon.jpg",
                  "creator": "example_maker",
                  "license": {
                    "id": "cc-by-nc",
                    "raw": "Creative Commons - Attribution - Non-Commercial"
                  },
                  "price": {
                    "type": "free",
                    "value": 0,
                    "currency": null,
                    "display": "Free"
                  },
                  "formats": [
                    "stl"
                  ],
                  "tags": [
                    "dragon",
                    "toy"
                  ],
                  "stats": {
                    "likes": 51234,
                    "comments": 870,
                    "makes": 3120,
                    "collects": 61000,
                    "downloads": 410000,
                    "views": 990000
                  },
                  "publishedAt": "2021-01-17T10:21:00Z",
                  "description": "The dragon prints in one piece, no supports needed…",
                  "images": [
                    "https://cdn.thingiverse.com/assets/dragon.jpg"
                  ],
                  "creatorUrl": "https://www.thingiverse.com/example_maker",
                  "category": "Toys & Games",
                  "updatedAt": "2021-02-02T08:00:00Z",
                  "copies": [
                    {
                      "source": "printables",
                      "id": "pr-123456"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "未提供令牌（`unauthorized`），或令牌无效、已被撤销（`invalid_token`）。"
          },
          "403": {
            "description": "令牌所有者尚未接受Polyzon的最新条款（`account_action_required`），请登录账号处理；或者该IP地址今天已有其他账号在使用（`too_many_accounts`）。"
          },
          "404": {
            "description": "模型不存在（`not_found`）。"
          },
          "410": {
            "description": "模型已应权利人要求删除（`gone`）。请在你的系统中同步删除。"
          },
          "429": {
            "description": "超出每分钟速率限制（`rate_limited`）、每日配额已用完（`quota_exceeded`），或IP地址的每日上限已用完（`address_quota_exceeded`）。请在`Retry-After`指定的秒数后重试。"
          },
          "503": {
            "description": "目录或令牌校验服务暂时不可用（`unavailable`）。请稍后重试。"
          }
        }
      }
    },
    "/v1/me": {
      "get": {
        "operationId": "getMe",
        "summary": "账号与令牌",
        "description": "查询发起本次请求的令牌属于哪个账号。不消耗每日配额。",
        "x-daily-quota": false,
        "parameters": [],
        "responses": {
          "200": {
            "description": "账号与令牌信息。",
            "content": {
              "application/json": {
                "example": {
                  "account": {
                    "id": "0f8c2a4e-…",
                    "displayName": "张伟",
                    "createdAt": "2026-03-14T10:00:00.000Z"
                  },
                  "token": {
                    "id": "7d0e2f8a-…",
                    "name": "Telegram机器人",
                    "prefix": "pzk_Q7xR2mVb",
                    "createdAt": "2026-10-09T08:15:00.000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "未提供令牌（`unauthorized`），或令牌无效、已被撤销（`invalid_token`）。"
          },
          "403": {
            "description": "令牌所有者尚未接受Polyzon的最新条款（`account_action_required`），请登录账号处理；或者该IP地址今天已有其他账号在使用（`too_many_accounts`）。"
          },
          "429": {
            "description": "超出每分钟速率限制（`rate_limited`）、每日配额已用完（`quota_exceeded`），或IP地址的每日上限已用完（`address_quota_exceeded`）。请在`Retry-After`指定的秒数后重试。"
          },
          "503": {
            "description": "目录或令牌校验服务暂时不可用（`unavailable`）。请稍后重试。"
          }
        }
      }
    },
    "/v1/limits": {
      "get": {
        "operationId": "getLimits",
        "summary": "剩余配额",
        "description": "每分钟窗口和UTC自然日的上限、已用量、剩余量及重置时间（Unix时间戳，单位为秒）。不消耗每日配额。",
        "x-daily-quota": false,
        "parameters": [],
        "responses": {
          "200": {
            "description": "账号的各个配额窗口。",
            "content": {
              "application/json": {
                "example": {
                  "perMinute": {
                    "limit": 20,
                    "used": 1,
                    "remaining": 19,
                    "resetAt": 1791579180
                  },
                  "daily": {
                    "limit": 200,
                    "used": 37,
                    "remaining": 163,
                    "resetAt": 1791590400
                  }
                }
              }
            }
          },
          "401": {
            "description": "未提供令牌（`unauthorized`），或令牌无效、已被撤销（`invalid_token`）。"
          },
          "403": {
            "description": "令牌所有者尚未接受Polyzon的最新条款（`account_action_required`），请登录账号处理；或者该IP地址今天已有其他账号在使用（`too_many_accounts`）。"
          },
          "429": {
            "description": "超出每分钟速率限制（`rate_limited`）、每日配额已用完（`quota_exceeded`），或IP地址的每日上限已用完（`address_quota_exceeded`）。请在`Retry-After`指定的秒数后重试。"
          },
          "503": {
            "description": "目录或令牌校验服务暂时不可用（`unavailable`）。请稍后重试。"
          }
        }
      }
    }
  }
}