{"openapi":"3.1.0","info":{"title":"TryCode API","version":"1.0.0","description":"Версионированный REST API для записей TryCode. Все запросы требуют API-ключ. Лимиты на ключ в минуту: GET — 120, POST — 10, PATCH и DELETE — 60; счётчики раздельные."},"servers":[{"url":"/"}],"security":[{"BearerAuth":[]}],"paths":{"/api/v1/codes":{"get":{"summary":"List your posts","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},{"name":"cursor","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Page of posts","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/RecordSummary"}},"nextCursor":{"type":["string","null"]}},"required":["data","nextCursor"]}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Create post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordInput"}}}},"responses":{"201":{"description":"Post","content":{"application/json":{"schema":{"type":"object","properties":{"record":{"$ref":"#/components/schemas/Record"}},"required":["record"]}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/codes/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^(?:[A-Z0-9]{3,10}|[a-bd-z]-[A-Z0-9]{3,10})$"}}],"get":{"summary":"Get your post","responses":{"200":{"description":"Post","content":{"application/json":{"schema":{"type":"object","properties":{"record":{"$ref":"#/components/schemas/Record"}},"required":["record"]}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"summary":"Update your post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordPatch"}}}},"responses":{"200":{"description":"Post","content":{"application/json":{"schema":{"type":"object","properties":{"record":{"$ref":"#/components/schemas/Record"}},"required":["record"]}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete your post","responses":{"200":{"description":"Post deleted"},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/public/codes":{"get":{"summary":"Public post catalog","parameters":[{"name":"q","in":"query","schema":{"type":"string","maxLength":80}},{"name":"language","in":"query","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},{"name":"cursor","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Page of public posts","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PublicRecordSummary"}},"nextCursor":{"type":["string","null"]}},"required":["data","nextCursor"]}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/public/codes/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^(?:[A-Z0-9]{3,10}|[a-bd-z]-[A-Z0-9]{3,10})$"}}],"get":{"summary":"Read a public post","description":"Reading another user's post counts toward its view limit. Password-protected posts return 423.","responses":{"200":{"description":"Post","content":{"application/json":{"schema":{"type":"object","properties":{"record":{"$ref":"#/components/schemas/Record"}},"required":["record"]}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"423":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API key","description":"A tc_live_… key created on /api"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["error"]},"RecordSummary":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"language":{"type":"string"},"isPublic":{"type":"boolean"},"allowOthersToEdit":{"type":"boolean"},"passwordProtected":{"type":"boolean"},"expiresAt":{"type":["integer","null"]},"maxViews":{"type":["integer","null"]},"burnAfterRead":{"type":"boolean"},"viewCount":{"type":"integer"},"lastViewAt":{"type":["integer","null"],"description":"Время последнего зафиксированного просмотра в миллисекундах UTC; null, если данных нет"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}},"required":["id","title","language","isPublic","viewCount","createdAt","updatedAt"]},"Record":{"allOf":[{"$ref":"#/components/schemas/RecordSummary"},{"type":"object","properties":{"content":{"type":"string"},"canEdit":{"type":"boolean"},"isOwner":{"type":"boolean"}},"required":["content"]}]},"PublicRecordSummary":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"language":{"type":"string"},"preview":{"type":["string","null"]},"author":{"type":["string","null"]},"passwordProtected":{"type":"boolean"},"viewCount":{"type":"integer"},"createdAt":{"type":"integer"}},"required":["id","title","language","preview","author","passwordProtected","viewCount","createdAt"]},"RecordFields":{"type":"object","properties":{"title":{"type":"string","maxLength":120},"language":{"type":"string","enum":["text","javascript","typescript","html","css","json","python","java","cpp","csharp","go","rust","php","ruby","sql","markdown","shell","yaml"],"default":"text"},"content":{"type":"string","description":"Не более 1 МиБ в UTF-8; полный JSON-запрос — не более 2 МиБ"},"isPublic":{"type":"boolean"},"allowOthersToEdit":{"type":"boolean"},"password":{"type":["string","null"],"minLength":6,"maxLength":128},"expiresAt":{"type":["integer","null"],"description":"Unix time in milliseconds"},"maxViews":{"type":["integer","null"],"minimum":1,"maximum":10000},"burnAfterRead":{"type":"boolean"}},"additionalProperties":false},"RecordInput":{"allOf":[{"$ref":"#/components/schemas/RecordFields"},{"type":"object","required":["content"]}]},"RecordPatch":{"$ref":"#/components/schemas/RecordFields","description":"All fields are optional; password: null removes protection"}}}}